Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2022-12-11 10:16:10
Exec Total Coverage
Lines: 1405 3902 36.0%
Functions: 121 337 35.9%
Branches: 709 2740 25.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 11 #include "zc_sys.h"
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte use_dwm_flush;
90 byte use_save_indicator;
91 byte midi_patch_fix;
92 bool midi_paused=false;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte callback_switchin = 0;
96 byte zc_192b163_warp_compatibility;
97 char modulepath[2048];
98 byte epilepsyFlashReduction;
99 signed char pause_in_background_menu_init = 0;
100 byte pause_in_background = 0;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
11 bool is_sys_pal = false;
102 extern PALETTE* hw_palette;
103 extern bool update_hw_pal;
104 extern const char* dmaplist(int32_t index, int32_t* list_size);
105
106
107 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
108 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
109 //extern byte refresh_select_screen;
110 //extern movingblock mblock2; //mblock[4]?
111 //extern int32_t db;
112
113 static const char *ZC_str = "Zelda Classic";
114 extern char save_file_name[1024];
115 #ifdef ALLEGRO_DOS
116 const char *qst_dir_name = "dos_qst_dir";
117 #elif defined(ALLEGRO_WINDOWS)
118 const char *qst_dir_name = "win_qst_dir";
119 static const char *qst_module_name = "current_module";
120 #elif defined(ALLEGRO_LINUX)
121 const char *qst_dir_name = "linux_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(__APPLE__)
124 const char *qst_dir_name = "osx_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #endif
127 #ifdef ALLEGRO_LINUX
128 static const char *samplepath = "samplesoundset/patches.dat";
129 #endif
130 char qst_files_path[2048];
131
132 #ifdef _MSC_VER
133 #define getcwd _getcwd
134 #endif
135
136 bool rF11();
137 bool rI();
138 bool rQ();
139 bool zc_key_pressed();
140
141 #ifdef _WIN32
142
143 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
144 extern "C"
145 {
146 typedef HRESULT(WINAPI *t_DwmFlush)();
147 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
148 }
149
150 void do_DwmFlush()
151 {
152 static HMODULE shell = LoadLibrary("dwmapi.dll");
153
154 if(!shell)
155 return;
156
157 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
158 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
159
160 BOOL enabled;
161 isEnabled(&enabled);
162
163 if(isEnabled)
164 flush();
165 }
166
167 #endif // _WIN32
168
169 // Dialogue largening
170 void large_dialog(DIALOG *d)
171 {
172 large_dialog(d, 1.5);
173 }
174
175 void large_dialog(DIALOG *d, float RESIZE_AMT)
176 {
177 if(!d[0].d1)
178 {
179 d[0].d1 = 1;
180 int32_t oldwidth = d[0].w;
181 int32_t oldheight = d[0].h;
182 int32_t oldx = d[0].x;
183 int32_t oldy = d[0].y;
184 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
185 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
186 d[0].w = int32_t(d[0].w*RESIZE_AMT);
187 d[0].h = int32_t(d[0].h*RESIZE_AMT);
188
189 for(int32_t i=1; d[i].proc !=NULL; i++)
190 {
191 // Place elements horizontally
192 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
193 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
194
195 if(d[i].proc != d_stringloader)
196 {
197 if(d[i].proc==d_bitmap_proc)
198 {
199 d[i].w *= 2;
200 }
201 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
202 }
203
204 // Place elements vertically
205 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
206 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
207
208 // Vertically resize elements
209 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
210 {
211 d[i].h = int32_t((double)d[i].h*1.5);
212 }
213 else if(d[i].proc == jwin_droplist_proc)
214 {
215 d[i].y += int32_t((double)d[i].h*0.25);
216 d[i].h = int32_t((double)d[i].h*1.25);
217 }
218 else if(d[i].proc==d_bitmap_proc)
219 {
220 d[i].h *= 2;
221 }
222 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
223
224 // Fix frames
225 if(d[i].proc == jwin_frame_proc)
226 {
227 d[i].x++;
228 d[i].y++;
229 d[i].w-=4;
230 d[i].h-=4;
231 }
232 }
233 }
234
235 for(int32_t i=1; d[i].proc!=NULL; i++)
236 {
237 if(d[i].proc==jwin_slider_proc)
238 continue;
239
240 // Bigger font
241 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
242
243 if(!d[i].dp2 && bigfontproc)
244 {
245 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
246 d[i].dp2 = lfont_l;
247 }
248 else if(!bigfontproc)
249 {
250 // ((ListData *)d[i].dp)->font = &sfont3;
251 ((ListData *)d[i].dp)->font = &lfont_l;
252 }
253
254 // Make checkboxes work
255 if(d[i].proc == jwin_check_proc)
256 d[i].proc = jwin_checkfont_proc;
257 else if(d[i].proc == jwin_radio_proc)
258 d[i].proc = jwin_radiofont_proc;
259 }
260
261 jwin_center_dialog(d);
262 }
263
264
265 /**********************************/
266 /******** System functions ********/
267 /**********************************/
268
269 static char cfg_sect[] = "zeldadx"; //We need to rename this.
270 static char ctrl_sect[] = "Controls";
271 static char sfx_sect[] = "Volume";
272
273 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
274 {
275 return D_O_K;
276 }
277
278 11 void load_game_configs()
279 {
280 11 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
281 11 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
282 11 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
283 11 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
284 11 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
285 11 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
286 11 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
287 11 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
288 11 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
289 11 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
290 11 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
291 11 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
292 11 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
293 11 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
294 11 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
295
296 //cheat modifier keya
297 11 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
298 11 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
299 11 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
300 11 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
301
302
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
303 joystick_index = 0;
304
305 11 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
306 11 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
307 11 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
308 11 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
309 11 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
310 11 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
311 11 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
312 11 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
313 11 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
314 11 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
315
316 11 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
317 11 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
318 11 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
319 11 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
320
321 11 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
322 11 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
323 11 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
324 11 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
325 11 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
326 11 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
327 11 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
328 11 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
329 11 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
330 11 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
331 11 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
332
333 11 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
334 11 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
335 11 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
336 11 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
337
338 11 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
339
340 11 digi_volume = zc_get_config(sfx_sect,"digi",248);
341 11 midi_volume = zc_get_config(sfx_sect,"midi",255);
342 11 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
343 11 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
344 11 pan_style = zc_get_config(sfx_sect,"pan",1);
345 // 1 <= zcmusic_bufsz <= 128
346 11 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
347 11 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
348 11 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
349 11 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
350 11 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
351 11 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
352 11 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
353 #ifdef __EMSCRIPTEN__
354 if (em_is_mobile()) NameEntryMode = 2;
355 #endif
356 11 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
357 11 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
358 11 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
359 11 title_version = zc_get_config(cfg_sect,"title",2);
360 11 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
361 11 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
362
363 //default - scale x2, 640 x 480
364 11 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
365 11 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
366 11 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
367 11 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
368 11 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
369
370 11 loadlast = zc_get_config(cfg_sect,"load_last",0);
371
372 11 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
373
374 11 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
375
376 //workaround for the 100% CPU bug. -Gleeok
377 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
378 11 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
379 #else
380 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
381 #endif
382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 frame_rest_suggest = zc_min(2, frame_rest_suggest);
383
384 11 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
385
386 #ifdef _WIN32
387 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
388 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
389 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
390 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
391
392 // This one's for Aero
393 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
394
395 // And this one fixes patches unloading on some MIDI setups
396 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
397 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
398 #else //UNIX
399 11 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
400 11 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
401 11 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
402 #endif
403 11 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
404
405 11 char const* default_path = "";
406 11 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
407
408
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(strlen(qstdir)==0)
409 {
410 11 getcwd(qstdir,2048);
411 11 fix_filename_case(qstdir);
412 11 fix_filename_slashes(qstdir);
413 11 put_backslash(qstdir);
414 11 }
415 else
416 {
417 chop_path(qstdir);
418 }
419
420 11 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
421 11 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
422 11 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
423 11 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
424 11 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
425 11 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
426 11 gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
427 11 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
428 11 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
429 11 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
430 11 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
431 11 }
432
433 void save_control_configs(bool kb)
434 {
435 if(kb)
436 {
437 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
438 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
439 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
440 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
441
442 if (!replay_is_replaying())
443 {
444 zc_set_config(ctrl_sect,"key_a",Akey);
445 zc_set_config(ctrl_sect,"key_b",Bkey);
446 zc_set_config(ctrl_sect,"key_s",Skey);
447 zc_set_config(ctrl_sect,"key_l",Lkey);
448 zc_set_config(ctrl_sect,"key_r",Rkey);
449 zc_set_config(ctrl_sect,"key_p",Pkey);
450 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
451 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
452 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
453 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
454 zc_set_config(ctrl_sect,"key_up", DUkey);
455 zc_set_config(ctrl_sect,"key_down", DDkey);
456 zc_set_config(ctrl_sect,"key_left", DLkey);
457 zc_set_config(ctrl_sect,"key_right",DRkey);
458 }
459 }
460 else
461 {
462 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
463 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
464 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
465 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
466 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
467 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
468 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
469 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
470 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
471 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
472 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
473 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
474 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
475 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
476
477 zc_set_config(ctrl_sect,"btn_a",Abtn);
478 zc_set_config(ctrl_sect,"btn_b",Bbtn);
479 zc_set_config(ctrl_sect,"btn_s",Sbtn);
480 zc_set_config(ctrl_sect,"btn_m",Mbtn);
481 zc_set_config(ctrl_sect,"btn_l",Lbtn);
482 zc_set_config(ctrl_sect,"btn_r",Rbtn);
483 zc_set_config(ctrl_sect,"btn_p",Pbtn);
484 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
485 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
486 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
487 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
488
489 zc_set_config(ctrl_sect,"btn_up",DUbtn);
490 zc_set_config(ctrl_sect,"btn_down",DDbtn);
491 zc_set_config(ctrl_sect,"btn_left",DLbtn);
492 zc_set_config(ctrl_sect,"btn_right",DRbtn);
493 }
494 }
495
496 void save_game_configs()
497 {
498 packfile_password("");
499
500 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
501
502 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
503 {
504 int o_window_x, o_window_y;
505 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
506 zc_set_config(cfg_sect,"window_x",o_window_x);
507 zc_set_config(cfg_sect,"window_y",o_window_y);
508 }
509
510 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
511 {
512 double monitor_scale = zc_get_monitor_scale();
513 window_width = al_get_display_width(all_get_display()) / monitor_scale;
514 window_height = al_get_display_height(all_get_display()) / monitor_scale;
515 zc_set_config(cfg_sect,"window_width",window_width);
516 zc_set_config(cfg_sect,"window_height",window_height);
517 }
518
519 zc_set_config(cfg_sect,"load_last",loadlast);
520 chop_path(qstdir);
521 zc_set_config(cfg_sect,qst_dir_name,qstdir);
522 zc_set_config("SAVEFILE","save_filename",save_file_name);
523 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
524 zc_set_config(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
525
526 flush_config_file();
527 #ifdef __EMSCRIPTEN__
528 em_sync_fs();
529 #endif
530 }
531
532 //----------------------------------------------------------------
533
534 // Timers
535
536 5378 void fps_callback()
537 {
538 5378 lastfps=framecnt;
539 5378 dword tempsecs = fps_secs;
540 5378 ++tempsecs;
541 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
542 5378 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
543 5378 ++fps_secs;
544 5378 framecnt=0;
545 5378 }
546
547 END_OF_FUNCTION(fps_callback)
548
549 11 int32_t Z_init_timers()
550 {
551 static bool didit = false;
552 const static char *err_str = "Couldn't allocate timer";
553 11 err_str = err_str; //Unused variable warning
554
555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(didit)
556 return 1;
557
558 11 didit = true;
559
560 LOCK_VARIABLE(lastfps);
561 LOCK_VARIABLE(framecnt);
562 LOCK_FUNCTION(fps_callback);
563
564
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
565 return 0;
566
567 11 return 1;
568 11 }
569
570 void Z_remove_timers()
571 {
572 remove_int(fps_callback);
573 }
574
575 //----------------------------------------------------------------
576
577 void go()
578 {
579 scare_mouse();
580 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
581 unscare_mouse();
582 }
583
584 void comeback()
585 {
586 scare_mouse();
587 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
588 unscare_mouse();
589 }
590
591 void dump_pal(BITMAP *dest)
592 {
593 for(int32_t i=0; i<256; i++)
594 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
595 }
596
597 //----------------------------------------------------------------
598
599 //Handles converting the mouse sprite from the .dat file
600 11 void load_mouse()
601 {
602 11 system_pal();
603 11 scare_mouse();
604 11 set_mouse_sprite(NULL);
605
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 int32_t sz = vbound(int32_t(16*(is_large ? zc_get_config("zeldadx","cursor_scale_large",1.5) : zc_get_config("zeldadx","cursor_scale_small",1))),16,80);
606
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t j = 0; j < 4; ++j)
607 {
608 44 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
609 44 BITMAP* subbmp = create_bitmap_ex(8,16,16);
610
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(zcmouse[j])
611 destroy_bitmap(zcmouse[j]);
612 44 zcmouse[j] = create_bitmap_ex(8,sz,sz);
613 44 clear_bitmap(zcmouse[j]);
614 44 clear_bitmap(tmpbmp);
615 44 clear_bitmap(subbmp);
616 44 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
617
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 44 times.
748 for(int32_t x = 0; x < 16; ++x)
618 {
619
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 704 times.
11968 for(int32_t y = 0; y < 16; ++y)
620 {
621 11264 int32_t color = getpixel(tmpbmp, x, y);
622
5/5
✓ Branch 0 taken 10362 times.
✓ Branch 1 taken 209 times.
✓ Branch 2 taken 242 times.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 198 times.
11264 switch(color)
623 {
624 case dvc(1):
625 209 color = jwin_pal[jcCURSORMISC];
626 209 break;
627 case dvc(2):
628 242 color = jwin_pal[jcCURSOROUTLINE];
629 242 break;
630 case dvc(3):
631 253 color = jwin_pal[jcCURSORLIGHT];
632 253 break;
633 case dvc(5):
634 198 color = jwin_pal[jcCURSORDARK];
635 198 break;
636 }
637 11264 putpixel(subbmp, x, y, color);
638 11264 }
639 704 }
640
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(sz!=16)
641 44 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
642 else
643 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
644 44 destroy_bitmap(tmpbmp);
645 44 destroy_bitmap(subbmp);
646 44 }
647 11 set_mouse_sprite(zcmouse[0]);
648
649 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
650 11 set_palette(*hw_palette);
651 11 show_mouse(screen);
652 11 show_mouse(NULL);
653
654 11 unscare_mouse();
655 11 game_pal();
656 11 }
657
658 // sets the video mode and initializes the palette and mouse sprite
659 11 bool game_vid_mode(int32_t mode,int32_t wait)
660 {
661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
662 {
663 return false;
664 }
665
666 11 scrx = (resx-320)>>1;
667 11 scry = (resy-240)>>1;
668
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t q = 0; q < 4; ++q)
669 44 zcmouse[q] = NULL;
670 11 load_mouse();
671 11 set_mouse_sprite(zcmouse[0]);
672
673
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 11 times.
187 for(int32_t i=240; i<256; i++)
674 176 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
675
676 11 set_palette(RAMpal);
677 11 clear_to_color(screen,BLACK);
678
679 11 rest(wait);
680 11 return true;
681 11 }
682
683 2 void null_quest()
684 {
685 char qstdat_string[2048];
686 2 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
687 2 strcat(qstdat_string,"#NESQST_NEW_QST");
688
689 #ifdef __EMSCRIPTEN__
690 // The quest template data file is not included because it's really big and isn't really needed
691 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
692 // which is much smaller.
693 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
694 #endif
695
696 2 byte skip_flags[4] = { 0 };
697
698 2 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
699 2 }
700
701 2 void init_NES_mode()
702 {
703 /*
704 // qst.dat may not load correctly without this...
705 QHeader.templatepath[0]='\0';
706
707 if(!init_colordata(true, &QHeader, &QMisc))
708 {
709 return;
710 }
711
712 loadfullpal();
713 init_tiles(false, &QHeader);
714 */
715 2 null_quest();
716 2 }
717
718 //----------------------------------------------------------------
719
720 qword trianglelines[16]=
721 {
722 0x0000000000000000ULL,
723 0xFD00000000000000ULL,
724 0xFDFD000000000000ULL,
725 0xFDFDFD0000000000ULL,
726 0xFDFDFDFD00000000ULL,
727 0xFDFDFDFDFD000000ULL,
728 0xFDFDFDFDFDFD0000ULL,
729 0xFDFDFDFDFDFDFD00ULL,
730 0xFDFDFDFDFDFDFDFDULL,
731 0x00FDFDFDFDFDFDFDULL,
732 0x0000FDFDFDFDFDFDULL,
733 0x000000FDFDFDFDFDULL,
734 0x00000000FDFDFDFDULL,
735 0x0000000000FDFDFDULL,
736 0x000000000000FDFDULL,
737 0x00000000000000FDULL,
738 };
739
740 word screen_triangles[28][32];
741 /*
742 qword triangles[4][16]= //[direction][value]
743 {
744 {
745 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
746 },
747 {
748 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
749 },
750 {
751 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
752 },
753 {
754 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
755 }
756 };
757 */
758
759
760 /*
761 byte triangles[4][16][8]= //[direction][value][line]
762 {
763 {
764 {
765 0, 0, 0, 0, 0, 0, 0, 0
766 },
767 {
768 1, 0, 0, 0, 0, 0, 0, 0
769 },
770 {
771 2, 1, 0, 0, 0, 0, 0, 0
772 },
773 {
774 3, 2, 1, 0, 0, 0, 0, 0
775 },
776 {
777 4, 3, 2, 1, 0, 0, 0, 0
778 },
779 {
780 5, 4, 3, 2, 1, 0, 0, 0
781 },
782 {
783 6, 5, 4, 3, 2, 1, 0, 0
784 },
785 {
786 7, 6, 5, 4, 3, 2, 1, 0
787 },
788 {
789 8, 7, 6, 5, 4, 3, 2, 1
790 },
791 {
792 8, 8, 7, 6, 5, 4, 3, 2
793 },
794 {
795 8, 8, 8, 7, 6, 5, 4, 3
796 },
797 {
798 8, 8, 8, 8, 7, 6, 5, 4
799 },
800 {
801 8, 8, 8, 8, 8, 7, 6, 5
802 },
803 {
804 8, 8, 8, 8, 8, 8, 7, 6
805 },
806 {
807 8, 8, 8, 8, 8, 8, 8, 7
808 },
809 {
810 8, 8, 8, 8, 8, 8, 8, 8
811 }
812 },
813 {
814 {
815 0, 0, 0, 0, 0, 0, 0, 0
816 },
817 {
818 15, 0, 0, 0, 0, 0, 0, 0
819 },
820 {
821 14, 15, 0, 0, 0, 0, 0, 0
822 },
823 {
824 13, 14, 15, 0, 0, 0, 0, 0
825 },
826 {
827 12, 13, 14, 15, 0, 0, 0, 0
828 },
829 {
830 11, 12, 13, 14, 15, 0, 0, 0
831 },
832 {
833 10, 11, 12, 13, 14, 15, 0, 0
834 },
835 {
836 9, 10, 11, 12, 13, 14, 15, 0
837 },
838 {
839 8, 9, 10, 11, 12, 13, 14, 15
840 },
841 {
842 8, 8, 9, 10, 11, 12, 13, 14
843 },
844 {
845 8, 8, 8, 9, 10, 11, 12, 13
846 },
847 {
848 8, 8, 8, 8, 9, 10, 11, 12
849 },
850 {
851 8, 8, 8, 8, 8, 9, 10, 11
852 },
853 {
854 8, 8, 8, 8, 8, 8, 9, 10
855 },
856 {
857 8, 8, 8, 8, 8, 8, 8, 9
858 },
859 {
860 8, 8, 8, 8, 8, 8, 8, 8
861 }
862 },
863 {
864 {
865 0, 0, 0, 0, 0, 0, 0, 0
866 },
867 {
868 0, 0, 0, 0, 0, 0, 0, 1
869 },
870 {
871 0, 0, 0, 0, 0, 0, 1, 2
872 },
873 {
874 0, 0, 0, 0, 0, 1, 2, 3
875 },
876 {
877 0, 0, 0, 0, 1, 2, 3, 4
878 },
879 {
880 0, 0, 0, 1, 2, 3, 4, 5
881 },
882 {
883 0, 0, 1, 2, 3, 4, 5, 6
884 },
885 {
886 0, 1, 2, 3, 4, 5, 6, 7
887 },
888 {
889 1, 2, 3, 4, 5, 6, 7, 8
890 },
891 {
892 2, 3, 4, 5, 6, 7, 8, 8
893 },
894 {
895 3, 4, 5, 6, 7, 8, 8, 8
896 },
897 {
898 4, 5, 6, 7, 8, 8, 8, 8
899 },
900 {
901 5, 6, 7, 8, 8, 8, 8, 8
902 },
903 {
904 6, 7, 8, 8, 8, 8, 8, 8
905 },
906 {
907 7, 8, 8, 8, 8, 8, 8, 8
908 },
909 {
910 8, 8, 8, 8, 8, 8, 8, 8
911 }
912 },
913 {
914 {
915 0, 0, 0, 0, 0, 0, 0, 0
916 },
917 {
918 0, 0, 0, 0, 0, 0, 0, 15
919 },
920 {
921 0, 0, 0, 0, 0, 0, 15, 14
922 },
923 {
924 0, 0, 0, 0, 0, 15, 14, 13
925 },
926 {
927 0, 0, 0, 0, 15, 14, 13, 12
928 },
929 {
930 0, 0, 0, 15, 14, 13, 12, 11
931 },
932 {
933 0, 0, 15, 14, 13, 12, 11, 10
934 },
935 {
936 0, 15, 14, 13, 12, 11, 10, 9
937 },
938 {
939 15, 14, 13, 12, 11, 10, 9, 8
940 },
941 {
942 14, 13, 12, 11, 10, 9, 8, 8
943 },
944 {
945 13, 12, 11, 10, 9, 8, 8, 8
946 },
947 {
948 12, 11, 10, 9, 8, 8, 8, 8
949 },
950 {
951 11, 10, 9, 8, 8, 8, 8, 8
952 },
953 {
954 10, 9, 8, 8, 8, 8, 8, 8
955 },
956 {
957 9, 8, 8, 8, 8, 8, 8, 8
958 },
959 {
960 8, 8, 8, 8, 8, 8, 8, 8
961 }
962 }
963 };
964 */
965
966
967
968 /*
969 for (int32_t blockrow=0; blockrow<30; ++i)
970 {
971 for (int32_t linerow=0; linerow<8; ++i)
972 {
973 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
974 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
975 {
976 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
977 ++triangleline;
978 }
979 }
980 }
981 */
982
983 // the ULL suffixes are to prevent this warning:
984 // warning: integer constant is too large for "int32_t" type
985
986 qword triangles[4][16][8]= //[direction][value][line]
987 {
988 {
989 {
990 0x0000000000000000ULL,
991 0x0000000000000000ULL,
992 0x0000000000000000ULL,
993 0x0000000000000000ULL,
994 0x0000000000000000ULL,
995 0x0000000000000000ULL,
996 0x0000000000000000ULL,
997 0x0000000000000000ULL
998 },
999 {
1000 0xFD00000000000000ULL,
1001 0x0000000000000000ULL,
1002 0x0000000000000000ULL,
1003 0x0000000000000000ULL,
1004 0x0000000000000000ULL,
1005 0x0000000000000000ULL,
1006 0x0000000000000000ULL,
1007 0x0000000000000000ULL
1008 },
1009 {
1010 0xFDFD000000000000ULL,
1011 0xFD00000000000000ULL,
1012 0x0000000000000000ULL,
1013 0x0000000000000000ULL,
1014 0x0000000000000000ULL,
1015 0x0000000000000000ULL,
1016 0x0000000000000000ULL,
1017 0x0000000000000000ULL
1018 },
1019 {
1020 0xFDFDFD0000000000ULL,
1021 0xFDFD000000000000ULL,
1022 0xFD00000000000000ULL,
1023 0x0000000000000000ULL,
1024 0x0000000000000000ULL,
1025 0x0000000000000000ULL,
1026 0x0000000000000000ULL,
1027 0x0000000000000000ULL
1028 },
1029 {
1030 0xFDFDFDFD00000000ULL,
1031 0xFDFDFD0000000000ULL,
1032 0xFDFD000000000000ULL,
1033 0xFD00000000000000ULL,
1034 0x0000000000000000ULL,
1035 0x0000000000000000ULL,
1036 0x0000000000000000ULL,
1037 0x0000000000000000ULL
1038 },
1039 {
1040 0xFDFDFDFDFD000000ULL,
1041 0xFDFDFDFD00000000ULL,
1042 0xFDFDFD0000000000ULL,
1043 0xFDFD000000000000ULL,
1044 0xFD00000000000000ULL,
1045 0x0000000000000000ULL,
1046 0x0000000000000000ULL,
1047 0x0000000000000000ULL
1048 },
1049 {
1050 0xFDFDFDFDFDFD0000ULL,
1051 0xFDFDFDFDFD000000ULL,
1052 0xFDFDFDFD00000000ULL,
1053 0xFDFDFD0000000000ULL,
1054 0xFDFD000000000000ULL,
1055 0xFD00000000000000ULL,
1056 0x0000000000000000ULL,
1057 0x0000000000000000ULL
1058 },
1059 {
1060 0xFDFDFDFDFDFDFD00ULL,
1061 0xFDFDFDFDFDFD0000ULL,
1062 0xFDFDFDFDFD000000ULL,
1063 0xFDFDFDFD00000000ULL,
1064 0xFDFDFD0000000000ULL,
1065 0xFDFD000000000000ULL,
1066 0xFD00000000000000ULL,
1067 0x0000000000000000ULL
1068 },
1069 {
1070 0xFDFDFDFDFDFDFDFDULL,
1071 0xFDFDFDFDFDFDFD00ULL,
1072 0xFDFDFDFDFDFD0000ULL,
1073 0xFDFDFDFDFD000000ULL,
1074 0xFDFDFDFD00000000ULL,
1075 0xFDFDFD0000000000ULL,
1076 0xFDFD000000000000ULL,
1077 0xFD00000000000000ULL
1078 },
1079 {
1080 0xFDFDFDFDFDFDFDFDULL,
1081 0xFDFDFDFDFDFDFDFDULL,
1082 0xFDFDFDFDFDFDFD00ULL,
1083 0xFDFDFDFDFDFD0000ULL,
1084 0xFDFDFDFDFD000000ULL,
1085 0xFDFDFDFD00000000ULL,
1086 0xFDFDFD0000000000ULL,
1087 0xFDFD000000000000ULL
1088 },
1089 {
1090 0xFDFDFDFDFDFDFDFDULL,
1091 0xFDFDFDFDFDFDFDFDULL,
1092 0xFDFDFDFDFDFDFDFDULL,
1093 0xFDFDFDFDFDFDFD00ULL,
1094 0xFDFDFDFDFDFD0000ULL,
1095 0xFDFDFDFDFD000000ULL,
1096 0xFDFDFDFD00000000ULL,
1097 0xFDFDFD0000000000ULL
1098 },
1099 {
1100 0xFDFDFDFDFDFDFDFDULL,
1101 0xFDFDFDFDFDFDFDFDULL,
1102 0xFDFDFDFDFDFDFDFDULL,
1103 0xFDFDFDFDFDFDFDFDULL,
1104 0xFDFDFDFDFDFDFD00ULL,
1105 0xFDFDFDFDFDFD0000ULL,
1106 0xFDFDFDFDFD000000ULL,
1107 0xFDFDFDFD00000000ULL
1108 },
1109 {
1110 0xFDFDFDFDFDFDFDFDULL,
1111 0xFDFDFDFDFDFDFDFDULL,
1112 0xFDFDFDFDFDFDFDFDULL,
1113 0xFDFDFDFDFDFDFDFDULL,
1114 0xFDFDFDFDFDFDFDFDULL,
1115 0xFDFDFDFDFDFDFD00ULL,
1116 0xFDFDFDFDFDFD0000ULL,
1117 0xFDFDFDFDFD000000ULL
1118 },
1119 {
1120 0xFDFDFDFDFDFDFDFDULL,
1121 0xFDFDFDFDFDFDFDFDULL,
1122 0xFDFDFDFDFDFDFDFDULL,
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFDFDULL,
1125 0xFDFDFDFDFDFDFDFDULL,
1126 0xFDFDFDFDFDFDFD00ULL,
1127 0xFDFDFDFDFDFD0000ULL
1128 },
1129 {
1130 0xFDFDFDFDFDFDFDFDULL,
1131 0xFDFDFDFDFDFDFDFDULL,
1132 0xFDFDFDFDFDFDFDFDULL,
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFDFDULL,
1136 0xFDFDFDFDFDFDFDFDULL,
1137 0xFDFDFDFDFDFDFD00ULL
1138 },
1139 {
1140 0xFDFDFDFDFDFDFDFDULL,
1141 0xFDFDFDFDFDFDFDFDULL,
1142 0xFDFDFDFDFDFDFDFDULL,
1143 0xFDFDFDFDFDFDFDFDULL,
1144 0xFDFDFDFDFDFDFDFDULL,
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFDFDULL,
1147 0xFDFDFDFDFDFDFDFDULL
1148 }
1149 },
1150 {
1151 {
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL,
1159 0x0000000000000000ULL
1160 },
1161 {
1162 0x00000000000000FDULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL,
1169 0x0000000000000000ULL
1170 },
1171 {
1172 0x000000000000FDFDULL,
1173 0x00000000000000FDULL,
1174 0x0000000000000000ULL,
1175 0x0000000000000000ULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL,
1179 0x0000000000000000ULL
1180 },
1181 {
1182 0x0000000000FDFDFDULL,
1183 0x000000000000FDFDULL,
1184 0x00000000000000FDULL,
1185 0x0000000000000000ULL,
1186 0x0000000000000000ULL,
1187 0x0000000000000000ULL,
1188 0x0000000000000000ULL,
1189 0x0000000000000000ULL
1190 },
1191 {
1192 0x00000000FDFDFDFDULL,
1193 0x0000000000FDFDFDULL,
1194 0x000000000000FDFDULL,
1195 0x00000000000000FDULL,
1196 0x0000000000000000ULL,
1197 0x0000000000000000ULL,
1198 0x0000000000000000ULL,
1199 0x0000000000000000ULL
1200 },
1201 {
1202 0x000000FDFDFDFDFDULL,
1203 0x00000000FDFDFDFDULL,
1204 0x0000000000FDFDFDULL,
1205 0x000000000000FDFDULL,
1206 0x00000000000000FDULL,
1207 0x0000000000000000ULL,
1208 0x0000000000000000ULL,
1209 0x0000000000000000ULL
1210 },
1211 {
1212 0x0000FDFDFDFDFDFDULL,
1213 0x000000FDFDFDFDFDULL,
1214 0x00000000FDFDFDFDULL,
1215 0x0000000000FDFDFDULL,
1216 0x000000000000FDFDULL,
1217 0x00000000000000FDULL,
1218 0x0000000000000000ULL,
1219 0x0000000000000000ULL
1220 },
1221 {
1222 0x00FDFDFDFDFDFDFDULL,
1223 0x0000FDFDFDFDFDFDULL,
1224 0x000000FDFDFDFDFDULL,
1225 0x00000000FDFDFDFDULL,
1226 0x0000000000FDFDFDULL,
1227 0x000000000000FDFDULL,
1228 0x00000000000000FDULL,
1229 0x0000000000000000ULL
1230 },
1231 {
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0x00FDFDFDFDFDFDFDULL,
1234 0x0000FDFDFDFDFDFDULL,
1235 0x000000FDFDFDFDFDULL,
1236 0x00000000FDFDFDFDULL,
1237 0x0000000000FDFDFDULL,
1238 0x000000000000FDFDULL,
1239 0x00000000000000FDULL
1240 },
1241 {
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0x00FDFDFDFDFDFDFDULL,
1245 0x0000FDFDFDFDFDFDULL,
1246 0x000000FDFDFDFDFDULL,
1247 0x00000000FDFDFDFDULL,
1248 0x0000000000FDFDFDULL,
1249 0x000000000000FDFDULL
1250 },
1251 {
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0x00FDFDFDFDFDFDFDULL,
1256 0x0000FDFDFDFDFDFDULL,
1257 0x000000FDFDFDFDFDULL,
1258 0x00000000FDFDFDFDULL,
1259 0x0000000000FDFDFDULL
1260 },
1261 {
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0x00FDFDFDFDFDFDFDULL,
1267 0x0000FDFDFDFDFDFDULL,
1268 0x000000FDFDFDFDFDULL,
1269 0x00000000FDFDFDFDULL
1270 },
1271 {
1272 0xFDFDFDFDFDFDFDFDULL,
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0x00FDFDFDFDFDFDFDULL,
1278 0x0000FDFDFDFDFDFDULL,
1279 0x000000FDFDFDFDFDULL
1280 },
1281 {
1282 0xFDFDFDFDFDFDFDFDULL,
1283 0xFDFDFDFDFDFDFDFDULL,
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0xFDFDFDFDFDFDFDFDULL,
1287 0xFDFDFDFDFDFDFDFDULL,
1288 0x00FDFDFDFDFDFDFDULL,
1289 0x0000FDFDFDFDFDFDULL
1290 },
1291 {
1292 0xFDFDFDFDFDFDFDFDULL,
1293 0xFDFDFDFDFDFDFDFDULL,
1294 0xFDFDFDFDFDFDFDFDULL,
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0xFDFDFDFDFDFDFDFDULL,
1298 0xFDFDFDFDFDFDFDFDULL,
1299 0x00FDFDFDFDFDFDFDULL
1300 },
1301 {
1302 0xFDFDFDFDFDFDFDFDULL,
1303 0xFDFDFDFDFDFDFDFDULL,
1304 0xFDFDFDFDFDFDFDFDULL,
1305 0xFDFDFDFDFDFDFDFDULL,
1306 0xFDFDFDFDFDFDFDFDULL,
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0xFDFDFDFDFDFDFDFDULL,
1309 0xFDFDFDFDFDFDFDFDULL
1310 }
1311 },
1312 {
1313 {
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL,
1321 0x0000000000000000ULL
1322 },
1323 {
1324 0x0000000000000000ULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL,
1331 0xFD00000000000000ULL
1332 },
1333 {
1334 0x0000000000000000ULL,
1335 0x0000000000000000ULL,
1336 0x0000000000000000ULL,
1337 0x0000000000000000ULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0xFD00000000000000ULL,
1341 0xFDFD000000000000ULL
1342 },
1343 {
1344 0x0000000000000000ULL,
1345 0x0000000000000000ULL,
1346 0x0000000000000000ULL,
1347 0x0000000000000000ULL,
1348 0x0000000000000000ULL,
1349 0xFD00000000000000ULL,
1350 0xFDFD000000000000ULL,
1351 0xFDFDFD0000000000ULL
1352 },
1353 {
1354 0x0000000000000000ULL,
1355 0x0000000000000000ULL,
1356 0x0000000000000000ULL,
1357 0x0000000000000000ULL,
1358 0xFD00000000000000ULL,
1359 0xFDFD000000000000ULL,
1360 0xFDFDFD0000000000ULL,
1361 0xFDFDFDFD00000000ULL
1362 },
1363 {
1364 0x0000000000000000ULL,
1365 0x0000000000000000ULL,
1366 0x0000000000000000ULL,
1367 0xFD00000000000000ULL,
1368 0xFDFD000000000000ULL,
1369 0xFDFDFD0000000000ULL,
1370 0xFDFDFDFD00000000ULL,
1371 0xFDFDFDFDFD000000ULL
1372 },
1373 {
1374 0x0000000000000000ULL,
1375 0x0000000000000000ULL,
1376 0xFD00000000000000ULL,
1377 0xFDFD000000000000ULL,
1378 0xFDFDFD0000000000ULL,
1379 0xFDFDFDFD00000000ULL,
1380 0xFDFDFDFDFD000000ULL,
1381 0xFDFDFDFDFDFD0000ULL
1382 },
1383 {
1384 0x0000000000000000ULL,
1385 0xFD00000000000000ULL,
1386 0xFDFD000000000000ULL,
1387 0xFDFDFD0000000000ULL,
1388 0xFDFDFDFD00000000ULL,
1389 0xFDFDFDFDFD000000ULL,
1390 0xFDFDFDFDFDFD0000ULL,
1391 0xFDFDFDFDFDFDFD00ULL
1392 },
1393 {
1394 0xFD00000000000000ULL,
1395 0xFDFD000000000000ULL,
1396 0xFDFDFD0000000000ULL,
1397 0xFDFDFDFD00000000ULL,
1398 0xFDFDFDFDFD000000ULL,
1399 0xFDFDFDFDFDFD0000ULL,
1400 0xFDFDFDFDFDFDFD00ULL,
1401 0xFDFDFDFDFDFDFDFDULL
1402 },
1403 {
1404 0xFDFD000000000000ULL,
1405 0xFDFDFD0000000000ULL,
1406 0xFDFDFDFD00000000ULL,
1407 0xFDFDFDFDFD000000ULL,
1408 0xFDFDFDFDFDFD0000ULL,
1409 0xFDFDFDFDFDFDFD00ULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL
1412 },
1413 {
1414 0xFDFDFD0000000000ULL,
1415 0xFDFDFDFD00000000ULL,
1416 0xFDFDFDFDFD000000ULL,
1417 0xFDFDFDFDFDFD0000ULL,
1418 0xFDFDFDFDFDFDFD00ULL,
1419 0xFDFDFDFDFDFDFDFDULL,
1420 0xFDFDFDFDFDFDFDFDULL,
1421 0xFDFDFDFDFDFDFDFDULL
1422 },
1423 {
1424 0xFDFDFDFD00000000ULL,
1425 0xFDFDFDFDFD000000ULL,
1426 0xFDFDFDFDFDFD0000ULL,
1427 0xFDFDFDFDFDFDFD00ULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0xFDFDFDFDFDFDFDFDULL,
1431 0xFDFDFDFDFDFDFDFDULL
1432 },
1433 {
1434 0xFDFDFDFDFD000000ULL,
1435 0xFDFDFDFDFDFD0000ULL,
1436 0xFDFDFDFDFDFDFD00ULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL,
1441 0xFDFDFDFDFDFDFDFDULL
1442 },
1443 {
1444 0xFDFDFDFDFDFD0000ULL,
1445 0xFDFDFDFDFDFDFD00ULL,
1446 0xFDFDFDFDFDFDFDFDULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL,
1449 0xFDFDFDFDFDFDFDFDULL,
1450 0xFDFDFDFDFDFDFDFDULL,
1451 0xFDFDFDFDFDFDFDFDULL
1452 },
1453 {
1454 0xFDFDFDFDFDFDFD00ULL,
1455 0xFDFDFDFDFDFDFDFDULL,
1456 0xFDFDFDFDFDFDFDFDULL,
1457 0xFDFDFDFDFDFDFDFDULL,
1458 0xFDFDFDFDFDFDFDFDULL,
1459 0xFDFDFDFDFDFDFDFDULL,
1460 0xFDFDFDFDFDFDFDFDULL,
1461 0xFDFDFDFDFDFDFDFDULL
1462 },
1463 {
1464 0xFDFDFDFDFDFDFDFDULL,
1465 0xFDFDFDFDFDFDFDFDULL,
1466 0xFDFDFDFDFDFDFDFDULL,
1467 0xFDFDFDFDFDFDFDFDULL,
1468 0xFDFDFDFDFDFDFDFDULL,
1469 0xFDFDFDFDFDFDFDFDULL,
1470 0xFDFDFDFDFDFDFDFDULL,
1471 0xFDFDFDFDFDFDFDFDULL
1472 }
1473 },
1474 {
1475 {
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL
1484 },
1485 {
1486 0x0000000000000000ULL,
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x0000000000000000ULL,
1491 0x0000000000000000ULL,
1492 0x0000000000000000ULL,
1493 0x00000000000000FDULL
1494 },
1495 {
1496 0x0000000000000000ULL,
1497 0x0000000000000000ULL,
1498 0x0000000000000000ULL,
1499 0x0000000000000000ULL,
1500 0x0000000000000000ULL,
1501 0x0000000000000000ULL,
1502 0x00000000000000FDULL,
1503 0x000000000000FDFDULL
1504 },
1505 {
1506 0x0000000000000000ULL,
1507 0x0000000000000000ULL,
1508 0x0000000000000000ULL,
1509 0x0000000000000000ULL,
1510 0x0000000000000000ULL,
1511 0x00000000000000FDULL,
1512 0x000000000000FDFDULL,
1513 0x0000000000FDFDFDULL
1514 },
1515 {
1516 0x0000000000000000ULL,
1517 0x0000000000000000ULL,
1518 0x0000000000000000ULL,
1519 0x0000000000000000ULL,
1520 0x00000000000000FDULL,
1521 0x000000000000FDFDULL,
1522 0x0000000000FDFDFDULL,
1523 0x00000000FDFDFDFDULL
1524 },
1525 {
1526 0x0000000000000000ULL,
1527 0x0000000000000000ULL,
1528 0x0000000000000000ULL,
1529 0x00000000000000FDULL,
1530 0x000000000000FDFDULL,
1531 0x0000000000FDFDFDULL,
1532 0x00000000FDFDFDFDULL,
1533 0x000000FDFDFDFDFDULL
1534 },
1535 {
1536 0x0000000000000000ULL,
1537 0x0000000000000000ULL,
1538 0x00000000000000FDULL,
1539 0x000000000000FDFDULL,
1540 0x0000000000FDFDFDULL,
1541 0x00000000FDFDFDFDULL,
1542 0x000000FDFDFDFDFDULL,
1543 0x0000FDFDFDFDFDFDULL
1544 },
1545 {
1546 0x0000000000000000ULL,
1547 0x00000000000000FDULL,
1548 0x000000000000FDFDULL,
1549 0x0000000000FDFDFDULL,
1550 0x00000000FDFDFDFDULL,
1551 0x000000FDFDFDFDFDULL,
1552 0x0000FDFDFDFDFDFDULL,
1553 0x00FDFDFDFDFDFDFDULL
1554 },
1555 {
1556 0x00000000000000FDULL,
1557 0x000000000000FDFDULL,
1558 0x0000000000FDFDFDULL,
1559 0x00000000FDFDFDFDULL,
1560 0x000000FDFDFDFDFDULL,
1561 0x0000FDFDFDFDFDFDULL,
1562 0x00FDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL
1564 },
1565 {
1566 0x000000000000FDFDULL,
1567 0x0000000000FDFDFDULL,
1568 0x00000000FDFDFDFDULL,
1569 0x000000FDFDFDFDFDULL,
1570 0x0000FDFDFDFDFDFDULL,
1571 0x00FDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL
1574 },
1575 {
1576 0x0000000000FDFDFDULL,
1577 0x00000000FDFDFDFDULL,
1578 0x000000FDFDFDFDFDULL,
1579 0x0000FDFDFDFDFDFDULL,
1580 0x00FDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL,
1583 0xFDFDFDFDFDFDFDFDULL
1584 },
1585 {
1586 0x00000000FDFDFDFDULL,
1587 0x000000FDFDFDFDFDULL,
1588 0x0000FDFDFDFDFDFDULL,
1589 0x00FDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL,
1593 0xFDFDFDFDFDFDFDFDULL
1594 },
1595 {
1596 0x000000FDFDFDFDFDULL,
1597 0x0000FDFDFDFDFDFDULL,
1598 0x00FDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL,
1603 0xFDFDFDFDFDFDFDFDULL
1604 },
1605 {
1606 0x0000FDFDFDFDFDFDULL,
1607 0x00FDFDFDFDFDFDFDULL,
1608 0xFDFDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL,
1611 0xFDFDFDFDFDFDFDFDULL,
1612 0xFDFDFDFDFDFDFDFDULL,
1613 0xFDFDFDFDFDFDFDFDULL
1614 },
1615 {
1616 0x00FDFDFDFDFDFDFDULL,
1617 0xFDFDFDFDFDFDFDFDULL,
1618 0xFDFDFDFDFDFDFDFDULL,
1619 0xFDFDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL,
1621 0xFDFDFDFDFDFDFDFDULL,
1622 0xFDFDFDFDFDFDFDFDULL,
1623 0xFDFDFDFDFDFDFDFDULL
1624 },
1625 {
1626 0xFDFDFDFDFDFDFDFDULL,
1627 0xFDFDFDFDFDFDFDFDULL,
1628 0xFDFDFDFDFDFDFDFDULL,
1629 0xFDFDFDFDFDFDFDFDULL,
1630 0xFDFDFDFDFDFDFDFDULL,
1631 0xFDFDFDFDFDFDFDFDULL,
1632 0xFDFDFDFDFDFDFDFDULL,
1633 0xFDFDFDFDFDFDFDFDULL
1634 }
1635 }
1636 };
1637
1638 int32_t black_opening_count=0;
1639 int32_t black_opening_x,black_opening_y;
1640 int32_t black_opening_shape;
1641
1642 344 int32_t choose_opening_shape()
1643 {
1644 // First, count how many bits are set
1645 344 int32_t numBits=0;
1646 int32_t bitCounter;
1647
1648
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 344 times.
2064 for(int32_t i=0; i<bosMAX; i++)
1649 {
1650
2/2
✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 344 times.
1720 if(COOLSCROLL&(1<<i))
1651 344 numBits++;
1652 1720 }
1653
1654 // Shouldn't happen...
1655
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 if(numBits==0)
1656 return bosCIRCLE;
1657
1658 // Pick a bit
1659 344 bitCounter=zc_rand()%numBits+1;
1660
1661
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 for(int32_t i=0; i<bosMAX; i++)
1662 {
1663 // If this bit is set, decrement the bit counter
1664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 if(COOLSCROLL&(1<<i))
1665 344 bitCounter--;
1666
1667 // When the counter hits 0, return a value based on
1668 // which bit it stopped on.
1669 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1670
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 if(bitCounter==0)
1671 344 return i;
1672 }
1673
1674 // Shouldn't be necessary, but the compiler might complain, at least
1675 return bosCIRCLE;
1676 344 }
1677
1678 110 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1679 {
1680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1681
1682 110 int32_t w=256, h=224;
1683 110 int32_t blockrows=28, blockcolumns=32;
1684 110 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1685
1686
2/2
✓ Branch 0 taken 3080 times.
✓ Branch 1 taken 110 times.
3190 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1687 {
1688
2/2
✓ Branch 0 taken 98560 times.
✓ Branch 1 taken 3080 times.
101640 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1689 {
1690
2/2
✓ Branch 0 taken 52915 times.
✓ Branch 1 taken 45645 times.
98560 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1691 98560 }
1692 3080 }
1693
1694 110 black_opening_count = 66;
1695 110 black_opening_x = x;
1696 110 black_opening_y = y;
1697 110 lensclk = 0;
1698 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1699
1700
1701
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(black_opening_shape == bosFADEBLACK)
1702 {
1703 refreshTints();
1704 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1705 }
1706
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(wait)
1707 {
1708 FFCore.warpScriptCheck();
1709 for(int32_t i=0; i<66; i++)
1710 {
1711 draw_screen(tmpscr);
1712 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1713 syskeys();
1714 advanceframe(true);
1715
1716 if(Quit)
1717 {
1718 break;
1719 }
1720 }
1721 }
1722 110 }
1723
1724 234 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1725 {
1726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234 times.
234 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1727
1728 234 int32_t w=256, h=224;
1729 234 int32_t blockrows=28, blockcolumns=32;
1730 234 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1731
1732
2/2
✓ Branch 0 taken 6552 times.
✓ Branch 1 taken 234 times.
6786 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1733 {
1734
2/2
✓ Branch 0 taken 209664 times.
✓ Branch 1 taken 6552 times.
216216 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1735 {
1736
2/2
✓ Branch 0 taken 101519 times.
✓ Branch 1 taken 108145 times.
209664 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1737 209664 }
1738 6552 }
1739
1740 234 black_opening_count = -66;
1741 234 black_opening_x = x;
1742 234 black_opening_y = y;
1743 234 lensclk = 0;
1744
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(black_opening_shape == bosFADEBLACK)
1745 {
1746 refreshTints();
1747 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1748 }
1749
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 136 times.
234 if(wait)
1750 {
1751 136 FFCore.warpScriptCheck();
1752
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 8976 times.
9112 for(int32_t i=0; i<66; i++)
1753 {
1754 8976 draw_screen(tmpscr);
1755 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1756 8976 syskeys();
1757 8976 advanceframe(true);
1758
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8976 times.
8976 if(Quit)
1760 {
1761 break;
1762 }
1763 8976 }
1764 136 }
1765 234 }
1766
1767 22704 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1768 {
1769 22704 clear_to_color(tmp_scr,BLACK);
1770 22704 int32_t w=256, h=224;
1771
1772
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22704 times.
22704 switch(black_opening_shape)
1773 {
1774 case bosOVAL:
1775 {
1776 double new_w=(w/2)+abs(w/2-x);
1777 double new_h=(h/2)+abs(h/2-y);
1778 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1779 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1780 break;
1781 }
1782
1783 case bosTRIANGLE:
1784 {
1785 double new_w=(w/2)+abs(w/2-x);
1786 double new_h=(h/2)+abs(h/2-y);
1787 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1788 double P2= (PI/2);
1789 double P23=(2*PI/3);
1790 double P43=(4*PI/3);
1791 double Pa= (-4*PI*a/(3*max_a));
1792 double angle=P2+Pa;
1793 double a0=angle;
1794 double a2=angle+P23;
1795 double a4=angle+P43;
1796 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1797 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1798 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1799 0);
1800 break;
1801 }
1802
1803 case bosSMAS:
1804 {
1805 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1806
1807 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1808 {
1809 for(int32_t linerow=0; linerow<8; ++linerow)
1810 {
1811 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1812
1813 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1814 {
1815 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1816 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1817 [linerow];
1818 ++triangleline;
1819
1820 if(linerow==0)
1821 {
1822 }
1823 }
1824 }
1825 }
1826
1827 break;
1828 }
1829
1830 case bosFADEBLACK:
1831 {
1832 if(black_opening_count<0)
1833 {
1834 black_fade(zc_min(-black_opening_count,63));
1835 }
1836 else if(black_opening_count>0)
1837 {
1838 black_fade(63-zc_max(black_opening_count-3,0));
1839 }
1840 else black_fade(0);
1841 return; //no blitting from tmp_scr!
1842 }
1843
1844 22704 case bosCIRCLE:
1845 default:
1846 {
1847 22704 double new_w=(w/2)+abs(w/2-x);
1848 22704 double new_h=(h/2)+abs(h/2-y);
1849 22704 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1850 //circlefill(tmp_scr,x,y,a<<3,0);
1851 22704 circlefill(tmp_scr,x,y,r,0);
1852 22704 break;
1853 }
1854 }
1855
1856 22704 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1857 22704 }
1858
1859
1860 void black_fade(int32_t fadeamnt)
1861 {
1862 for(int32_t i=0; i < 0xEF; i++)
1863 {
1864 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1865 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1866 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1867 }
1868
1869 refreshpal = true;
1870 }
1871
1872 //----------------------------------------------------------------
1873
1874 9845155 bool item_disabled(int32_t item) //is this item disabled?
1875 {
1876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9845155 times.
9845155 return (item>=0 && game->items_off[item] != 0);
1877 }
1878
1879 2444430 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1880 {
1881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2444430 times.
2444430 if(current_item(item_type, true) >=item)
1882 {
1883 return true;
1884 }
1885
1886 2444430 return false;
1887 2444430 }
1888
1889 12109767 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1890 {
1891
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1769588 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1239166 times.
✓ Branch 6 taken 6848809 times.
✓ Branch 7 taken 2238905 times.
✓ Branch 8 taken 13299 times.
12109767 switch(item_type)
1892 {
1893 case itype_bomb:
1894 case itype_sbomb:
1895 {
1896 int32_t itemid = getItemID(itemsbuf, item_type, it);
1897
1898 if(itemid == -1)
1899 return false;
1900
1901 return (game->get_item(itemid));
1902 }
1903
1904 case itype_clock:
1905 {
1906 1769588 int32_t itemid = getItemID(itemsbuf, item_type, it);
1907
1908
2/4
✓ Branch 0 taken 1769588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1769588 times.
✗ Branch 3 not taken.
1769588 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1909 return (game->get_item(itemid));
1910 1769588 return Hero.getClock()?1:0;
1911 }
1912
1913 case itype_key:
1914 return (game->get_keys()>0);
1915
1916 case itype_magiccontainer:
1917 return (game->get_maxmagic()>=game->get_mp_per_block());
1918
1919 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1920 {
1921
1/3
✓ Branch 0 taken 1239166 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1239166 switch(it)
1922 {
1923 case -2:
1924 {
1925 for(int32_t i=0; i<MAXLEVELS; i++)
1926 {
1927 if(game->lvlitems[i]&liTRIFORCE)
1928 {
1929 return true;
1930 }
1931 }
1932
1933 return false;
1934 }
1935
1936 case -1:
1937 return (game->lvlitems[dlevel]&liTRIFORCE);
1938
1939 default:
1940
2/4
✓ Branch 0 taken 1239166 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1239166 times.
1239166 if(it>=0&&it<MAXLEVELS)
1941 {
1942 1239166 return (game->lvlitems[it]&liTRIFORCE);
1943 }
1944
1945 break;
1946 }
1947
1948 return 0;
1949 }
1950
1951 case itype_map: //it: -2=any, -1=current level, other=that level
1952 {
1953
1/3
✓ Branch 0 taken 6848809 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
6848809 switch(it)
1954 {
1955 case -2:
1956 {
1957 for(int32_t i=0; i<MAXLEVELS; i++)
1958 {
1959 if(game->lvlitems[i]&liMAP)
1960 {
1961 return true;
1962 }
1963 }
1964
1965 return false;
1966 }
1967
1968 case -1:
1969 return (game->lvlitems[dlevel]&liMAP)!=0;
1970
1971 default:
1972
2/4
✓ Branch 0 taken 6848809 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6848809 times.
6848809 if(it>=0&&it<MAXLEVELS)
1973 {
1974 6848809 return (game->lvlitems[it]&liMAP)!=0;
1975 }
1976
1977 break;
1978 }
1979
1980 return 0;
1981 }
1982
1983 case itype_compass: //it: -2=any, -1=current level, other=that level
1984 {
1985
1/3
✓ Branch 0 taken 2238905 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2238905 switch(it)
1986 {
1987 case -2:
1988 {
1989 for(int32_t i=0; i<MAXLEVELS; i++)
1990 {
1991 if(game->lvlitems[i]&liCOMPASS)
1992 {
1993 return true;
1994 }
1995 }
1996
1997 return false;
1998 }
1999
2000 case -1:
2001 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2002
2003 default:
2004
2/4
✓ Branch 0 taken 2238905 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2238905 times.
✗ Branch 3 not taken.
2238905 if(it>=0&&it<MAXLEVELS)
2005 {
2006 2238905 return (game->lvlitems[it]&liCOMPASS)!=0;
2007 }
2008
2009 break;
2010 }
2011 return 0;
2012 }
2013
2014 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2015 {
2016
1/3
✓ Branch 0 taken 13299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
13299 switch(it)
2017 {
2018 case -2:
2019 {
2020 for(int32_t i=0; i<MAXLEVELS; i++)
2021 {
2022 if(game->lvlitems[i]&liBOSSKEY)
2023 {
2024 return true;
2025 }
2026 }
2027
2028 return false;
2029 }
2030
2031 case -1:
2032 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2033
2034 default:
2035
2/4
✓ Branch 0 taken 13299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13299 times.
13299 if(it>=0&&it<MAXLEVELS)
2036 {
2037 13299 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2038 }
2039 break;
2040 }
2041 return 0;
2042 }
2043
2044 default:
2045 //it=(1<<(it-1));
2046 /*if (item_type>=itype_max)
2047 {
2048 system_pal();
2049 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2050 game_pal();
2051
2052 return false;
2053 }*/
2054 int32_t itemid = getItemID(itemsbuf, item_type, it);
2055
2056 if(itemid == -1)
2057 return false;
2058
2059 return game->get_item(itemid);
2060 }
2061 12109767 }
2062
2063
2064 29993789 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2065 {
2066
9/9
✓ Branch 0 taken 1769588 times.
✓ Branch 1 taken 15837085 times.
✓ Branch 2 taken 1769588 times.
✓ Branch 3 taken 1769588 times.
✓ Branch 4 taken 1769588 times.
✓ Branch 5 taken 1769588 times.
✓ Branch 6 taken 1769588 times.
✓ Branch 7 taken 1769588 times.
✓ Branch 8 taken 1769588 times.
29993789 switch(item_type)
2067 {
2068 case itype_clock:
2069 {
2070 1769588 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2071
2072
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1769588 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1769588 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2073 return itemsbuf[maxid].fam_type;
2074
2075 1769588 return has_item(itype_clock,1) ? 1 : 0;
2076 }
2077
2078 case itype_key:
2079 1769588 return game->get_keys();
2080
2081 case itype_lkey:
2082 1769588 return game->lvlkeys[get_dlevel()];
2083
2084 case itype_magiccontainer:
2085 1769588 return game->get_maxmagic()/game->get_mp_per_block();
2086
2087 case itype_triforcepiece:
2088 {
2089 1769588 int32_t count=0;
2090
2091
2/2
✓ Branch 0 taken 906029056 times.
✓ Branch 1 taken 1769588 times.
907798644 for(int32_t i=0; i<MAXLEVELS; i++)
2092 {
2093 906029056 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2094 906029056 }
2095
2096 1769588 return count;
2097 }
2098
2099 case itype_map:
2100 {
2101 1769588 int32_t count=0;
2102
2103
2/2
✓ Branch 0 taken 906029056 times.
✓ Branch 1 taken 1769588 times.
907798644 for(int32_t i=0; i<MAXLEVELS; i++)
2104 {
2105 906029056 count+=(game->lvlitems[i]&liMAP)?1:0;
2106 906029056 }
2107
2108 1769588 return count;
2109 }
2110
2111 case itype_compass:
2112 {
2113 1769588 int32_t count=0;
2114
2115
2/2
✓ Branch 0 taken 906029056 times.
✓ Branch 1 taken 1769588 times.
907798644 for(int32_t i=0; i<MAXLEVELS; i++)
2116 {
2117 906029056 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2118 906029056 }
2119
2120 1769588 return count;
2121 }
2122
2123 case itype_bosskey:
2124 {
2125 1769588 int32_t count=0;
2126
2127
2/2
✓ Branch 0 taken 906029056 times.
✓ Branch 1 taken 1769588 times.
907798644 for(int32_t i=0; i<MAXLEVELS; i++)
2128 {
2129 906029056 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2130 906029056 }
2131
2132 1769588 return count;
2133 }
2134
2135 default:
2136 15837085 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2137
2138
2/2
✓ Branch 0 taken 2755425 times.
✓ Branch 1 taken 13081660 times.
15837085 if(maxid == -1)
2139 13081660 return 0;
2140
2141 2755425 return itemsbuf[maxid].fam_type;
2142 }
2143 29993789 }
2144
2145 27549359 int32_t current_item(int32_t item_type) //item currently being used
2146 {
2147 27549359 return current_item(item_type, true);
2148 }
2149
2150 11 std::map<int32_t, int32_t> itemcache;
2151
2152 // Not actually used by anything at the moment...
2153 void removeFromItemCache(int32_t itemid)
2154 {
2155 itemcache.erase(itemid);
2156 }
2157
2158 8648 void flushItemCache()
2159 {
2160 8648 itemcache.clear();
2161
2162 //also fix the active subscreen if items were deleted -DD
2163
1/2
✓ Branch 0 taken 8648 times.
✗ Branch 1 not taken.
8648 if(game != NULL)
2164 {
2165 8648 verifyBothWeapons();
2166 8648 load_Sitems(&QMisc);
2167 8648 }
2168 8648 }
2169
2170 // This is used often, so it should be as direct as possible.
2171 998723587 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2172 {
2173
2/2
✓ Branch 0 taken 969542947 times.
✓ Branch 1 taken 29180640 times.
998723587 if(jinx_check)
2174 {
2175
4/4
✓ Branch 0 taken 16305596 times.
✓ Branch 1 taken 12875044 times.
✓ Branch 2 taken 12898570 times.
✓ Branch 3 taken 3407026 times.
29180640 if(!(HeroSwordClk() || HeroItemClk()))
2176 12898570 jinx_check = false; //not jinxed
2177 29180640 }
2178
4/4
✓ Branch 0 taken 991285069 times.
✓ Branch 1 taken 7438518 times.
✓ Branch 2 taken 16164591 times.
✓ Branch 3 taken 975120478 times.
998723587 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2179 {
2180 975120478 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2181
2182
2/2
✓ Branch 0 taken 970704345 times.
✓ Branch 1 taken 4416133 times.
975120478 if(res != itemcache.end())
2183 970704345 return res->second;
2184 4416133 }
2185
2186 28019242 int32_t result = -1;
2187 28019242 int32_t highestlevel = -1;
2188
2189
2/2
✓ Branch 0 taken 7172925952 times.
✓ Branch 1 taken 28019242 times.
7200945194 for(int32_t i=0; i<MAXITEMS; i++)
2190 {
2191
5/6
✓ Branch 0 taken 593073886 times.
✓ Branch 1 taken 6579852066 times.
✓ Branch 2 taken 9763913 times.
✓ Branch 3 taken 583309973 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9763913 times.
7172925952 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2192 {
2193
4/4
✓ Branch 0 taken 2507629 times.
✓ Branch 1 taken 7256284 times.
✓ Branch 2 taken 796913 times.
✓ Branch 3 taken 8967000 times.
9763913 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2194 {
2195 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2196
2/2
✓ Branch 0 taken 8966932 times.
✓ Branch 1 taken 68 times.
8967000 if(!checkmagiccost(i))
2197 {
2198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2199 }
2200 8966932 }
2201
6/6
✓ Branch 0 taken 8047315 times.
✓ Branch 1 taken 1716530 times.
✓ Branch 2 taken 166826 times.
✓ Branch 3 taken 1549704 times.
✓ Branch 4 taken 1065509 times.
✓ Branch 5 taken 651021 times.
9763845 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2202 {
2203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 651021 times.
651021 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2204 651021 continue;
2205 }
2206
2207
2/2
✓ Branch 0 taken 161484 times.
✓ Branch 1 taken 8951340 times.
9112824 if(itemsbuf[i].fam_type >= highestlevel)
2208 {
2209 8951340 highestlevel = itemsbuf[i].fam_type;
2210 8951340 result=i;
2211 8951340 }
2212 9112824 }
2213 7172274863 }
2214
2215
2/2
✓ Branch 0 taken 16282070 times.
✓ Branch 1 taken 11737172 times.
28019242 if(!jinx_check) //Can't cache jinx_check results
2216 11737172 itemcache[itemtype] = result;
2217 28019242 return result;
2218 998723587 }
2219
2220 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2221 982663621 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2222 {
2223 982663621 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2224
2/2
✓ Branch 0 taken 13120674 times.
✓ Branch 1 taken 969542947 times.
982663621 if(!jinx_check) //If not already a jinx-immune-only check...
2225 {
2226 //And the player IS jinxed...
2227
4/4
✓ Branch 0 taken 956840345 times.
✓ Branch 1 taken 12702602 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 953482981 times.
969542947 if(HeroSwordClk() || HeroItemClk())
2228 {
2229 //Then do a jinx-immune-only check here
2230 16059966 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2231 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2232 //Should NOT need a compat rule, as this should always return -1 in old quests.
2233
2/2
✓ Branch 0 taken 732810 times.
✓ Branch 1 taken 15327156 times.
16059966 if(ret2 > -1) return ret2;
2234 15327156 }
2235 968810137 }
2236 981930811 return ret;
2237 982663621 }
2238 7065047 int32_t current_item_power(int32_t itemtype)
2239 {
2240 7065047 int32_t result = current_item_id(itemtype,true);
2241
2/2
✓ Branch 0 taken 4551890 times.
✓ Branch 1 taken 2513157 times.
7065047 return (result<0) ? 0 : itemsbuf[result].power;
2242 }
2243
2244 4 int32_t heart_container_id()
2245 {
2246
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 for(int32_t i=0; i<MAXITEMS; i++)
2247 {
2248
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 112 times.
116 if(itemsbuf[i].family == itype_heartcontainer)
2249 {
2250 4 return i;
2251 }
2252 112 }
2253 return -1;
2254 4 }
2255
2256 1769588 int32_t item_tile_mod()
2257 {
2258 1769588 int32_t tile=0;
2259
2260
2/2
✓ Branch 0 taken 70928 times.
✓ Branch 1 taken 1698660 times.
1769588 if(game->get_bombs())
2261 {
2262 1698660 int32_t itemid = current_item_id(itype_bomb,false);
2263
2/4
✓ Branch 0 taken 1698660 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1698660 times.
1698660 if(itemid > -1 && checkbunny(itemid))
2264 1698660 tile+=itemsbuf[itemid].ltm;
2265 1698660 }
2266
2267
2/2
✓ Branch 0 taken 1331585 times.
✓ Branch 1 taken 438003 times.
1769588 if(game->get_sbombs())
2268 {
2269 438003 int32_t itemid = current_item_id(itype_sbomb,false);
2270
3/4
✓ Branch 0 taken 436575 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 436575 times.
438003 if(itemid > -1 && checkbunny(itemid))
2271 436575 tile+=itemsbuf[itemid].ltm;
2272 438003 }
2273
2274
2/2
✓ Branch 0 taken 1728684 times.
✓ Branch 1 taken 40904 times.
1769588 if(current_item(itype_clock))
2275 {
2276 40904 int32_t itemid =
2277
1/2
✓ Branch 0 taken 40904 times.
✗ Branch 1 not taken.
40904 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2278 ? iClock
2279 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2280
2/4
✓ Branch 0 taken 40904 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40904 times.
40904 if(itemid > -1 && checkbunny(itemid))
2281 40904 tile+=itemsbuf[itemid].ltm;
2282 40904 }
2283
2284
2/2
✓ Branch 0 taken 1229264 times.
✓ Branch 1 taken 540324 times.
1769588 if(current_item(itype_key))
2285 {
2286 540324 int32_t itemid =
2287
1/2
✓ Branch 0 taken 540324 times.
✗ Branch 1 not taken.
540324 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2288 ? iKey
2289 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2290
2/4
✓ Branch 0 taken 540324 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 540324 times.
540324 if(itemid > -1 && checkbunny(itemid))
2291 540324 tile+=itemsbuf[itemid].ltm;
2292 540324 }
2293
2294
2/2
✓ Branch 0 taken 1650791 times.
✓ Branch 1 taken 118797 times.
1769588 if(current_item(itype_lkey))
2295 {
2296 118797 int32_t itemid =
2297
1/2
✓ Branch 0 taken 118797 times.
✗ Branch 1 not taken.
118797 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2298 ? iLevelKey
2299 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2300
2/4
✓ Branch 0 taken 118797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 118797 times.
118797 if(itemid > -1 && checkbunny(itemid))
2301 118797 tile+=itemsbuf[itemid].ltm;
2302 118797 }
2303
2304
2/2
✓ Branch 0 taken 143159 times.
✓ Branch 1 taken 1626429 times.
1769588 if(current_item(itype_map))
2305 {
2306 1626429 int32_t itemid =
2307
1/2
✓ Branch 0 taken 1626429 times.
✗ Branch 1 not taken.
1626429 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2308 ? iMap
2309 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2310
2/4
✓ Branch 0 taken 1626429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1626429 times.
1626429 if(itemid > -1 && checkbunny(itemid))
2311 1626429 tile+=itemsbuf[itemid].ltm;
2312 1626429 }
2313
2314
2/2
✓ Branch 0 taken 80052 times.
✓ Branch 1 taken 1689536 times.
1769588 if(current_item(itype_compass))
2315 {
2316 1689536 int32_t itemid =
2317
1/2
✓ Branch 0 taken 1689536 times.
✗ Branch 1 not taken.
1689536 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2318 ? iCompass
2319 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2320
2/4
✓ Branch 0 taken 1689536 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1689536 times.
1689536 if(itemid > -1 && checkbunny(itemid))
2321 1689536 tile+=itemsbuf[itemid].ltm;
2322 1689536 }
2323
2324
2/2
✓ Branch 0 taken 501894 times.
✓ Branch 1 taken 1267694 times.
1769588 if(current_item(itype_bosskey))
2325 {
2326 1267694 int32_t itemid =
2327
1/2
✓ Branch 0 taken 1267694 times.
✗ Branch 1 not taken.
1267694 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2328 ? iBossKey
2329 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2330
2/4
✓ Branch 0 taken 1267694 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1267694 times.
1267694 if(itemid > -1 && checkbunny(itemid))
2331 1267694 tile+=itemsbuf[itemid].ltm;
2332 1267694 }
2333
2334
1/2
✓ Branch 0 taken 1769588 times.
✗ Branch 1 not taken.
1769588 if(current_item(itype_magiccontainer))
2335 {
2336 int32_t itemid =
2337 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2338 ? iMagicC
2339 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2340 if(itemid > -1 && checkbunny(itemid))
2341 tile+=itemsbuf[itemid].ltm;
2342 }
2343
2344
2/2
✓ Branch 0 taken 190440 times.
✓ Branch 1 taken 1579148 times.
1769588 if(current_item(itype_triforcepiece))
2345 {
2346 1579148 int32_t itemid =
2347
1/2
✓ Branch 0 taken 1579148 times.
✗ Branch 1 not taken.
1579148 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2348 ? iTriforce
2349 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2350
2/4
✓ Branch 0 taken 1579148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1579148 times.
1579148 if(itemid > -1 && checkbunny(itemid))
2351 1579148 tile+=itemsbuf[itemid].ltm;
2352 1579148 }
2353
2354
2/2
✓ Branch 0 taken 1769588 times.
✓ Branch 1 taken 906029056 times.
907798644 for(int32_t i=0; i<itype_max; i++)
2355 {
2356
2/2
✓ Branch 0 taken 900541952 times.
✓ Branch 1 taken 5487104 times.
906029056 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2357 {
2358
2/2
✓ Branch 0 taken 107170 times.
✓ Branch 1 taken 5379934 times.
5487104 switch(i)
2359 {
2360 case itype_bomb:
2361 case itype_sbomb:
2362 case itype_clock:
2363 case itype_key:
2364 case itype_lkey:
2365 case itype_map:
2366 case itype_compass:
2367 case itype_bosskey:
2368 case itype_magiccontainer:
2369 case itype_triforcepiece:
2370 107170 continue; //already handled
2371 }
2372 5379934 }
2373 905921886 int32_t itemid = current_item_id(i,false);
2374
2/2
✓ Branch 0 taken 904152298 times.
✓ Branch 1 taken 1769588 times.
905921886 if(i == itype_shield)
2375 1769588 itemid = getCurrentShield(false);
2376
2377
3/4
✓ Branch 0 taken 24545709 times.
✓ Branch 1 taken 881376177 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24545709 times.
905921886 if(itemid < 0 || !checkbunny(itemid))
2378 881376177 continue;
2379
2380 24545709 itemdata const& itm = itemsbuf[itemid];
2381
2382
2/2
✓ Branch 0 taken 22776121 times.
✓ Branch 1 taken 1769588 times.
24545709 switch(itm.family)
2383 {
2384 case itype_shield:
2385
1/2
✓ Branch 0 taken 1769588 times.
✗ Branch 1 not taken.
1769588 if(itm.flags & ITEM_FLAG9) //active shield
2386 {
2387 if(!usingActiveShield(itemid))
2388 {
2389 tile+=itm.misc6; //'Inactive PTM'
2390 continue;
2391 }
2392 }
2393 1769588 break;
2394 }
2395
2396 24545709 tile+=itm.ltm;
2397 24545709 }
2398
2399 1769588 return tile;
2400 }
2401
2402 1769588 int32_t bunny_tile_mod()
2403 {
2404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1769588 times.
1769588 if(Hero.BunnyClock())
2405 {
2406 return game->get_bunny_ltm();
2407 }
2408 1769588 return 0;
2409 1769588 }
2410
2411 // Hints are drawn on a separate layer to combo reveals.
2412 1248 void draw_lens_under(BITMAP *dest, bool layer)
2413 {
2414 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2415 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2416 //Lens flag 3: Don't show armos/chest/dive items
2417 //Lens flag 4: Show Raft Paths
2418 //Lens flag 5: Show Invisible Enemies
2419
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 624 times.
✓ Branch 3 taken 624 times.
1248 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2420
2421 1248 int32_t strike_hint_table[11]=
2422 {
2423 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2424 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2425 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2426 };
2427
2428 // int32_t page = tmpscr->cpage;
2429 {
2430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
1248 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2431 // int32_t temptimer=0;
2432 1248 int32_t tempitem, tempweapon=0;
2433 1248 strike_hint=strike_hint_table[strike_hint_counter];
2434
2435
2/2
✓ Branch 0 taken 1211 times.
✓ Branch 1 taken 37 times.
1248 if(strike_hint_timer>32)
2436 {
2437 37 strike_hint_timer=0;
2438 37 strike_hint_counter=((strike_hint_counter+1)%11);
2439 37 }
2440
2441 1248 ++strike_hint_timer;
2442
2443
2/2
✓ Branch 0 taken 219648 times.
✓ Branch 1 taken 1248 times.
220896 for(int32_t i=0; i<176; i++)
2444 {
2445 219648 int32_t x = (i & 15) << 4;
2446 219648 int32_t y = (i & 0xF0) + playing_field_offset;
2447 219648 int32_t tempitemx=-16, tempitemy=-16;
2448 219648 int32_t tempweaponx=-16, tempweapony=-16;
2449
2450
2/2
✓ Branch 0 taken 439296 times.
✓ Branch 1 taken 219648 times.
658944 for(int32_t iter=0; iter<2; ++iter)
2451 {
2452 439296 int32_t checkflag=0;
2453
2454
2/2
✓ Branch 0 taken 219648 times.
✓ Branch 1 taken 219648 times.
439296 if(iter==0)
2455 {
2456 219648 checkflag=combobuf[tmpscr->data[i]].flag;
2457 219648 }
2458 else
2459 {
2460 219648 checkflag=tmpscr->sflag[i];
2461 }
2462
2463
1/2
✓ Branch 0 taken 439296 times.
✗ Branch 1 not taken.
439296 if(checkflag==mfSTRIKE)
2464 {
2465 if(!hints)
2466 {
2467 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2468 }
2469 else
2470 {
2471 checkflag = strike_hint;
2472 }
2473 }
2474
2475
6/36
✓ Branch 0 taken 422304 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 528 times.
✓ Branch 5 taken 16176 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 96 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
439296 switch(checkflag)
2476 {
2477 case 0:
2478 case mfZELDA:
2479 case mfPUSHED:
2480 case mfENEMY0:
2481 case mfENEMY1:
2482 case mfENEMY2:
2483 case mfENEMY3:
2484 case mfENEMY4:
2485 case mfENEMY5:
2486 case mfENEMY6:
2487 case mfENEMY7:
2488 case mfENEMY8:
2489 case mfENEMY9:
2490 case mfSINGLE:
2491 case mfSINGLE16:
2492 case mfNOENEMY:
2493 case mfTRAP_H:
2494 case mfTRAP_V:
2495 case mfTRAP_4:
2496 case mfTRAP_LR:
2497 case mfTRAP_UD:
2498 case mfNOGROUNDENEMY:
2499 case mfNOBLOCKS:
2500 case mfSCRIPT1:
2501 case mfSCRIPT2:
2502 case mfSCRIPT3:
2503 case mfSCRIPT4:
2504 case mfSCRIPT5:
2505 case mfSCRIPT6:
2506 case mfSCRIPT7:
2507 case mfSCRIPT8:
2508 case mfSCRIPT9:
2509 case mfSCRIPT10:
2510 case mfSCRIPT11:
2511 case mfSCRIPT12:
2512 case mfSCRIPT13:
2513 case mfSCRIPT14:
2514 case mfSCRIPT15:
2515 case mfSCRIPT16:
2516 case mfSCRIPT17:
2517 case mfSCRIPT18:
2518 case mfSCRIPT19:
2519 case mfSCRIPT20:
2520 case mfPITHOLE:
2521 case mfPITFALLFLOOR:
2522 case mfLAVA:
2523 case mfICE:
2524 case mfICEDAMAGE:
2525 case mfDAMAGE1:
2526 case mfDAMAGE2:
2527 case mfDAMAGE4:
2528 case mfDAMAGE8:
2529 case mfDAMAGE16:
2530 case mfDAMAGE32:
2531 case mfFREEZEALL:
2532 case mfFREZEALLANSFFCS:
2533 case mfFREEZEFFCSOLY:
2534 case mfSCRITPTW1TRIG:
2535 case mfSCRITPTW2TRIG:
2536 case mfSCRITPTW3TRIG:
2537 case mfSCRITPTW4TRIG:
2538 case mfSCRITPTW5TRIG:
2539 case mfSCRITPTW6TRIG:
2540 case mfSCRITPTW7TRIG:
2541 case mfSCRITPTW8TRIG:
2542 case mfSCRITPTW9TRIG:
2543 case mfSCRITPTW10TRIG:
2544 case mfTROWEL:
2545 case mfTROWELNEXT:
2546 case mfTROWELSPECIALITEM:
2547 case mfSLASHPOT:
2548 case mfLIFTPOT:
2549 case mfLIFTORSLASH:
2550 case mfLIFTROCK:
2551 case mfLIFTROCKHEAVY:
2552 case mfDROPITEM:
2553 case mfSPECIALITEM:
2554 case mfDROPKEY:
2555 case mfDROPLKEY:
2556 case mfDROPCOMPASS:
2557 case mfDROPMAP:
2558 case mfDROPBOSSKEY:
2559 case mfSPAWNNPC:
2560 case mfSWITCHHOOK:
2561 case mfSIDEVIEWLADDER:
2562 case mfSIDEVIEWPLATFORM:
2563 case mfNOENEMYSPAWN:
2564 case mfENEMYALL:
2565 case mfNOMIRROR:
2566 case mfUNSAFEGROUND:
2567 case mf168:
2568 case mf169:
2569 case mf170:
2570 case mf171:
2571 case mf172:
2572 case mf173:
2573 case mf174:
2574 case mf175:
2575 case mf176:
2576 case mf177:
2577 case mf178:
2578 case mf179:
2579 case mf180:
2580 case mf181:
2581 case mf182:
2582 case mf183:
2583 case mf184:
2584 case mf185:
2585 case mf186:
2586 case mf187:
2587 case mf188:
2588 case mf189:
2589 case mf190:
2590 case mf191:
2591 case mf192:
2592 case mf193:
2593 case mf194:
2594 case mf195:
2595 case mf196:
2596 case mf197:
2597 case mf198:
2598 case mf199:
2599 case mf200:
2600 case mf201:
2601 case mf202:
2602 case mf203:
2603 case mf204:
2604 case mf205:
2605 case mf206:
2606 case mf207:
2607 case mf208:
2608 case mf209:
2609 case mf210:
2610 case mf211:
2611 case mf212:
2612 case mf213:
2613 case mf214:
2614 case mf215:
2615 case mf216:
2616 case mf217:
2617 case mf218:
2618 case mf219:
2619 case mf220:
2620 case mf221:
2621 case mf222:
2622 case mf223:
2623 case mf224:
2624 case mf225:
2625 case mf226:
2626 case mf227:
2627 case mf228:
2628 case mf229:
2629 case mf230:
2630 case mf231:
2631 case mf232:
2632 case mf233:
2633 case mf234:
2634 case mf235:
2635 case mf236:
2636 case mf237:
2637 case mf238:
2638 case mf239:
2639 case mf240:
2640 case mf241:
2641 case mf242:
2642 case mf243:
2643 case mf244:
2644 case mf245:
2645 case mf246:
2646 case mf247:
2647 case mf248:
2648 case mf249:
2649 case mf250:
2650 case mf251:
2651 case mf252:
2652 case mf253:
2653 case mf254:
2654 case mfEXTENDED:
2655 422304 break;
2656
2657 case mfPUSHUD:
2658 case mfPUSHLR:
2659 case mfPUSH4:
2660 case mfPUSHU:
2661 case mfPUSHD:
2662 case mfPUSHL:
2663 case mfPUSHR:
2664 case mfPUSHUDNS:
2665 case mfPUSHLRNS:
2666 case mfPUSH4NS:
2667 case mfPUSHUNS:
2668 case mfPUSHDNS:
2669 case mfPUSHLNS:
2670 case mfPUSHRNS:
2671 case mfPUSHUDINS:
2672 case mfPUSHLRINS:
2673 case mfPUSH4INS:
2674 case mfPUSHUINS:
2675 case mfPUSHDINS:
2676 case mfPUSHLINS:
2677 case mfPUSHRINS:
2678
3/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
168 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2679
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2680 {
2681 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2682 }
2683
2684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 168 times.
168 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2685
3/6
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
168 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2686 {
2687
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 42 times.
84 if(hints)
2688 {
2689
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
42 switch(combobuf[tmpscr->data[i]].type)
2690 {
2691 case cPUSH_HEAVY:
2692 case cPUSH_HW:
2693 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2694 tempitemx=x, tempitemy=y;
2695
2696 if(tempitem>-1)
2697 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2698
2699 break;
2700
2701 case cPUSH_HEAVY2:
2702 case cPUSH_HW2:
2703 42 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2704 42 tempitemx=x, tempitemy=y;
2705
2706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(tempitem>-1)
2707 42 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2708
2709 42 break;
2710 }
2711 42 }
2712 84 }
2713
2714 168 break;
2715
2716 case mfWHISTLE:
2717 if(hints)
2718 {
2719 tempitem=getItemID(itemsbuf,itype_whistle,1);
2720
2721 if(tempitem<0) break;
2722
2723 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2724 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2725 {
2726 tempitemx=x;
2727 tempitemy=y;
2728 }
2729
2730 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2731 }
2732
2733 break;
2734
2735 //Why is this here?
2736 case mfFAIRY:
2737 case mfMAGICFAIRY:
2738 case mfALLFAIRY:
2739 if(hints)
2740 {
2741 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2742
2743 if(tempitem < 0) break;
2744
2745 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2746 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2747 {
2748 tempitemx=x;
2749 tempitemy=y;
2750 }
2751
2752 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2753 }
2754
2755 break;
2756
2757 case mfBCANDLE:
2758 if(!hints)
2759 {
2760 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2761 }
2762 else
2763 {
2764 tempitem=getItemID(itemsbuf,itype_candle,1);
2765
2766 if(tempitem<0) break;
2767
2768 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2769 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2770 {
2771 tempitemx=x;
2772 tempitemy=y;
2773 }
2774
2775 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2776 }
2777
2778 break;
2779
2780 case mfRCANDLE:
2781 if(!hints)
2782 {
2783 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2784 }
2785 else
2786 {
2787 tempitem=getItemID(itemsbuf,itype_candle,2);
2788
2789 if(tempitem<0) break;
2790
2791 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2792 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2793 {
2794 tempitemx=x;
2795 tempitemy=y;
2796 }
2797
2798 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2799 }
2800
2801 break;
2802
2803 case mfWANDFIRE:
2804 if(!hints)
2805 {
2806 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2807 }
2808 else
2809 {
2810 tempitem=getItemID(itemsbuf,itype_wand,1);
2811
2812 if(tempitem<0) break;
2813
2814 tempweapon=wFire;
2815
2816 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2817 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2818 {
2819 tempitemx=x;
2820 tempitemy=y;
2821 }
2822 else
2823 {
2824 tempweaponx=x;
2825 tempweapony=y;
2826 }
2827
2828 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2829 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2830 }
2831
2832 break;
2833
2834 case mfDINSFIRE:
2835 if(!hints)
2836 {
2837 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2838 }
2839 else
2840 {
2841 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2842
2843 if(tempitem<0) break;
2844
2845 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2846 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2847 {
2848 tempitemx=x;
2849 tempitemy=y;
2850 }
2851
2852 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2853 }
2854
2855 break;
2856
2857 case mfARROW:
2858 if(!hints)
2859 {
2860 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2861 }
2862 else
2863 {
2864 tempitem=getItemID(itemsbuf,itype_arrow,1);
2865
2866 if(tempitem<0) break;
2867
2868 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2869 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2870 {
2871 tempitemx=x;
2872 tempitemy=y;
2873 }
2874
2875 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2876 }
2877
2878 break;
2879
2880 case mfSARROW:
2881 if(!hints)
2882 {
2883 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2884 }
2885 else
2886 {
2887 tempitem=getItemID(itemsbuf,itype_arrow,2);
2888
2889 if(tempitem<0) break;
2890
2891 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2892 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2893 {
2894 tempitemx=x;
2895 tempitemy=y;
2896 }
2897
2898 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2899 }
2900
2901 break;
2902
2903 case mfGARROW:
2904 if(!hints)
2905 {
2906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2907 }
2908 else
2909 {
2910 tempitem=getItemID(itemsbuf,itype_arrow,3);
2911
2912 if(tempitem<0) break;
2913
2914 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2915 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2916 {
2917 tempitemx=x;
2918 tempitemy=y;
2919 }
2920
2921 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2922 }
2923
2924 break;
2925
2926 case mfBOMB:
2927 if(!hints)
2928 {
2929 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2930 }
2931 else
2932 {
2933 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2934 tempweapon = wLitBomb;
2935
2936 //if (tempitem<0) break;
2937 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2938 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2939 {
2940 tempweaponx=x;
2941 tempweapony=y;
2942 }
2943
2944 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2945 }
2946
2947 break;
2948
2949 case mfSBOMB:
2950
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
2951 {
2952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2953 48 }
2954 else
2955 {
2956 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2957 //if (tempitem<0) break;
2958 48 tempweapon = wLitSBomb;
2959
2960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2961
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2962 {
2963 24 tempweaponx=x;
2964 24 tempweapony=y;
2965 24 }
2966
2967 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2968 }
2969
2970 96 break;
2971
2972 case mfARMOS_SECRET:
2973 if(!hints)
2974 {
2975 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2976 }
2977 break;
2978
2979 case mfBRANG:
2980 if(!hints)
2981 {
2982 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2983 }
2984 else
2985 {
2986 tempitem=getItemID(itemsbuf,itype_brang,1);
2987
2988 if(tempitem<0) break;
2989
2990 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2991 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2992 {
2993 tempitemx=x;
2994 tempitemy=y;
2995 }
2996
2997 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2998 }
2999
3000 break;
3001
3002 case mfMBRANG:
3003 if(!hints)
3004 {
3005 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3006 }
3007 else
3008 {
3009 tempitem=getItemID(itemsbuf,itype_brang,2);
3010
3011 if(tempitem<0) break;
3012
3013 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3014 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3015 {
3016 tempitemx=x;
3017 tempitemy=y;
3018 }
3019
3020 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3021 }
3022
3023 break;
3024
3025 case mfFBRANG:
3026 if(!hints)
3027 {
3028 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3029 }
3030 else
3031 {
3032 tempitem=getItemID(itemsbuf,itype_brang,3);
3033
3034 if(tempitem<0) break;
3035
3036 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3037 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3038 {
3039 tempitemx=x;
3040 tempitemy=y;
3041 }
3042
3043 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3044 }
3045
3046 break;
3047
3048 case mfWANDMAGIC:
3049 if(!hints)
3050 {
3051 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3052 }
3053 else
3054 {
3055 tempitem=getItemID(itemsbuf,itype_wand,1);
3056
3057 if(tempitem<0) break;
3058
3059 tempweapon=itemsbuf[tempitem].wpn3;
3060
3061 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3062 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3063 {
3064 tempitemx=x;
3065 tempitemy=y;
3066 }
3067 else
3068 {
3069 tempweaponx=x;
3070 tempweapony=y;
3071 --lens_hint_weapon[wMagic][4];
3072
3073 if(lens_hint_weapon[wMagic][4]<-8)
3074 {
3075 lens_hint_weapon[wMagic][4]=8;
3076 }
3077 }
3078
3079 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3080 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3081 }
3082
3083 break;
3084
3085 case mfREFMAGIC:
3086 if(!hints)
3087 {
3088 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3089 }
3090 else
3091 {
3092 tempitem=getItemID(itemsbuf,itype_shield,3);
3093
3094 if(tempitem<0) break;
3095
3096 tempweapon=ewMagic;
3097
3098 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3099 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3100 {
3101 tempitemx=x;
3102 tempitemy=y;
3103 }
3104 else
3105 {
3106 tempweaponx=x;
3107 tempweapony=y;
3108
3109 if(lens_hint_weapon[ewMagic][2]==up)
3110 {
3111 --lens_hint_weapon[ewMagic][4];
3112 }
3113 else
3114 {
3115 ++lens_hint_weapon[ewMagic][4];
3116 }
3117
3118 if(lens_hint_weapon[ewMagic][4]>8)
3119 {
3120 lens_hint_weapon[ewMagic][2]=up;
3121 }
3122
3123 if(lens_hint_weapon[ewMagic][4]<=0)
3124 {
3125 lens_hint_weapon[ewMagic][2]=down;
3126 }
3127 }
3128
3129 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3130 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3131 }
3132
3133 break;
3134
3135 case mfREFFIREBALL:
3136 if(!hints)
3137 {
3138 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3139 }
3140 else
3141 {
3142 tempitem=getItemID(itemsbuf,itype_shield,3);
3143
3144 if(tempitem<0) break;
3145
3146 tempweapon=ewFireball;
3147
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3149 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3150 {
3151 tempitemx=x;
3152 tempitemy=y;
3153 tempweaponx=x;
3154 tempweapony=y;
3155 ++lens_hint_weapon[ewFireball][3];
3156
3157 if(lens_hint_weapon[ewFireball][3]>8)
3158 {
3159 lens_hint_weapon[ewFireball][3]=-8;
3160 lens_hint_weapon[ewFireball][4]=8;
3161 }
3162
3163 if(lens_hint_weapon[ewFireball][3]>0)
3164 {
3165 ++lens_hint_weapon[ewFireball][4];
3166 }
3167 else
3168 {
3169 --lens_hint_weapon[ewFireball][4];
3170 }
3171 }
3172
3173 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3174 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3175 }
3176
3177 break;
3178
3179 case mfSWORD:
3180 if(!hints)
3181 {
3182 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3183 }
3184 else
3185 {
3186 tempitem=getItemID(itemsbuf,itype_sword,1);
3187
3188 if(tempitem<0) break;
3189
3190 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3191 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3192 {
3193 tempitemx=x;
3194 tempitemy=y;
3195 }
3196
3197 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3198 }
3199
3200 break;
3201
3202 case mfWSWORD:
3203 if(!hints)
3204 {
3205 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3206 }
3207 else
3208 {
3209 tempitem=getItemID(itemsbuf,itype_sword,2);
3210
3211 if(tempitem<0) break;
3212
3213 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3214 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3215 {
3216 tempitemx=x;
3217 tempitemy=y;
3218 }
3219
3220 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3221 }
3222
3223 break;
3224
3225 case mfMSWORD:
3226 if(!hints)
3227 {
3228 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3229 }
3230 else
3231 {
3232 tempitem=getItemID(itemsbuf,itype_sword,3);
3233
3234 if(tempitem<0) break;
3235
3236 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3237 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3238 {
3239 tempitemx=x;
3240 tempitemy=y;
3241 }
3242
3243 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3244 }
3245
3246 break;
3247
3248 case mfXSWORD:
3249 if(!hints)
3250 {
3251 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3252 }
3253 else
3254 {
3255 tempitem=getItemID(itemsbuf,itype_sword,4);
3256
3257 if(tempitem<0) break;
3258
3259 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3260 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3261 {
3262 tempitemx=x;
3263 tempitemy=y;
3264 }
3265
3266 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3267 }
3268
3269 break;
3270
3271 case mfSWORDBEAM:
3272 if(!hints)
3273 {
3274 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3275 }
3276 else
3277 {
3278 tempitem=getItemID(itemsbuf,itype_sword,1);
3279
3280 if(tempitem<0) break;
3281
3282 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3283 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3284 {
3285 tempitemx=x;
3286 tempitemy=y;
3287 }
3288
3289 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3290 }
3291
3292 break;
3293
3294 case mfWSWORDBEAM:
3295 if(!hints)
3296 {
3297 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3298 }
3299 else
3300 {
3301 tempitem=getItemID(itemsbuf,itype_sword,2);
3302
3303 if(tempitem<0) break;
3304
3305 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3306 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3307 {
3308 tempitemx=x;
3309 tempitemy=y;
3310 }
3311
3312 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3313 }
3314
3315 break;
3316
3317 case mfMSWORDBEAM:
3318 if(!hints)
3319 {
3320 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3321 }
3322 else
3323 {
3324 tempitem=getItemID(itemsbuf,itype_sword,3);
3325
3326 if(tempitem<0) break;
3327
3328 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3329 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3330 {
3331 tempitemx=x;
3332 tempitemy=y;
3333 }
3334
3335 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3336 }
3337
3338 break;
3339
3340 case mfXSWORDBEAM:
3341 if(!hints)
3342 {
3343 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3344 }
3345 else
3346 {
3347 tempitem=getItemID(itemsbuf,itype_sword,4);
3348
3349 if(tempitem<0) break;
3350
3351 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3352 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3353 {
3354 tempitemx=x;
3355 tempitemy=y;
3356 }
3357
3358 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3359 }
3360
3361 break;
3362
3363 case mfHOOKSHOT:
3364 if(!hints)
3365 {
3366 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3367 }
3368 else
3369 {
3370 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3371
3372 if(tempitem<0) break;
3373
3374 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3375 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3376 {
3377 tempitemx=x;
3378 tempitemy=y;
3379 }
3380
3381 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3382 }
3383
3384 break;
3385
3386 case mfWAND:
3387 if(!hints)
3388 {
3389 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3390 }
3391 else
3392 {
3393 tempitem=getItemID(itemsbuf,itype_wand,1);
3394
3395 if(tempitem<0) break;
3396
3397 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3398 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3399 {
3400 tempitemx=x;
3401 tempitemy=y;
3402 }
3403
3404 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3405 }
3406
3407 break;
3408
3409 case mfHAMMER:
3410 if(!hints)
3411 {
3412 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3413 }
3414 else
3415 {
3416 tempitem=getItemID(itemsbuf,itype_hammer,1);
3417
3418 if(tempitem<0) break;
3419
3420 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3421 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3422 {
3423 tempitemx=x;
3424 tempitemy=y;
3425 }
3426
3427 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3428 }
3429
3430 break;
3431
3432 case mfARMOS_ITEM:
3433 case mfDIVE_ITEM:
3434
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
528 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3435 {
3436 528 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3437 528 }
3438 528 break;
3439
3440 case 16:
3441 case 17:
3442 case 18:
3443 case 19:
3444 case 20:
3445 case 21:
3446 case 22:
3447 case 23:
3448 case 24:
3449 case 25:
3450 case 26:
3451 case 27:
3452 case 28:
3453 case 29:
3454 case 30:
3455 case 31:
3456
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
24 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3458 12 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3459
3460 24 break;
3461 case mfSECRETSNEXT:
3462 if(!hints)
3463 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3464 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3465
3466 break;
3467
3468 case mfSTRIKE:
3469 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3470 {
3471 goto special;
3472 }
3473 else
3474 {
3475 break;
3476 }
3477
3478 16176 default: goto special;
3479
3480 special:
3481
7/8
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 8088 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 7980 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 24 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8004 times.
16176 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3482 {
3483
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 42 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3484 {
3485 42 rectfill(dest,x,y,x+15,y+15,WHITE);
3486 42 }
3487 84 }
3488
3489 16176 break;
3490 }
3491 439296 }
3492 219648 }
3493
3494
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 624 times.
1248 if(layer)
3495 {
3496
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[0]==dWALK)
3497 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3498
3499
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[1]==dWALK)
3500 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3501
3502
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[2]==dWALK)
3503 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3504
3505
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[3]==dWALK)
3506 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3507
3508
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[0]==dBOMB)
3509 {
3510 showbombeddoor(dest, 0);
3511 }
3512
3513
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[1]==dBOMB)
3514 {
3515 showbombeddoor(dest, 1);
3516 }
3517
3518
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[2]==dBOMB)
3519 {
3520 showbombeddoor(dest, 2);
3521 }
3522
3523
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(tmpscr->door[3]==dBOMB)
3524 {
3525 showbombeddoor(dest, 3);
3526 }
3527 624 }
3528
3529
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 48 times.
1248 if(tmpscr->stairx + tmpscr->stairy)
3530 {
3531
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 if(!hints)
3532 {
3533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3534 24 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3535 24 }
3536 else
3537 {
3538
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tmpscr->flags&fWHISTLE)
3539 {
3540 tempitem=getItemID(itemsbuf,itype_whistle,1);
3541 int32_t tempitemx=-16;
3542 int32_t tempitemy=-16;
3543
3544 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3545 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3546 {
3547 tempitemx=tmpscr->stairx;
3548 tempitemy=tmpscr->stairy+playing_field_offset;
3549 }
3550
3551 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3552 }
3553 }
3554 48 }
3555 }
3556 1248 }
3557
3558 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3559
3560 624 void draw_lens_over()
3561 {
3562 // Oh, what the heck.
3563 static BITMAP *lens_scr = NULL;
3564 static int32_t last_width = -1;
3565 624 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3566
3567 // Only redraw the circle if the size has changed
3568
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 1 times.
624 if(width != last_width)
3569 {
3570
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(lens_scr == NULL)
3571 {
3572 1 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3573 1 }
3574
3575 1 clear_to_color(lens_scr, BLACK);
3576 1 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3577 1 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3578 1 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3579 1 last_width=width;
3580 1 }
3581
3582 624 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3583 624 }
3584
3585 //----------------------------------------------------------------
3586
3587 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3588 {
3589 //recreating a big bitmap every frame is highly sluggish.
3590 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3591 clear_to_color(wavebuf, BLACK);
3592 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3593
3594 int32_t ofs;
3595 // int32_t amplitude=8;
3596 // int32_t wavelength=4;
3597 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3598 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3599 int32_t amp2=168;
3600 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3601 int32_t i=frame%amp2;
3602
3603 for(int32_t j=0; j<168; j++)
3604 {
3605 if(j&1 && interpol)
3606 {
3607 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3608 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3609 }
3610 else
3611 {
3612 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3613 }
3614
3615 if(ofs)
3616 {
3617 for(int32_t k=0; k<256; k++)
3618 {
3619 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3620 }
3621 }
3622 }
3623 }
3624
3625 384 void draw_fuzzy(int32_t fuzz)
3626 // draws from right half of scrollbuf to framebuf
3627 {
3628 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3629 byte *start, *si, *di;
3630
3631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(fuzz<1)
3632 fuzz = 1;
3633
3634 384 xstep = 128%fuzz;
3635
3636
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 304 times.
384 if(xstep > 0)
3637 304 xstep = fuzz-xstep;
3638
3639 384 ystep = 112%fuzz;
3640
3641
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 272 times.
384 if(ystep > 0)
3642 272 ystep = fuzz-ystep;
3643
3644 384 firsty = 1;
3645
3646
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 13856 times.
14240 for(y=0; y<224;)
3647 {
3648 13856 start = &(scrollbuf->line[y][256]);
3649
3650
4/4
✓ Branch 0 taken 13664 times.
✓ Branch 1 taken 86208 times.
✓ Branch 2 taken 86016 times.
✓ Branch 3 taken 13856 times.
99872 for(dy=0; dy<ystep && dy+y<224; dy++)
3651 {
3652 86016 si = start;
3653 86016 di = &(framebuf->line[y+dy][0]);
3654 86016 i = xstep;
3655 86016 firstx = 1;
3656
3657
2/2
✓ Branch 0 taken 22020096 times.
✓ Branch 1 taken 86016 times.
22106112 for(dx=0; dx<256; dx++)
3658 {
3659 22020096 *(di++) = *si;
3660
3661
2/2
✓ Branch 0 taken 18554368 times.
✓ Branch 1 taken 3465728 times.
22020096 if(++i >= fuzz)
3662 {
3663
2/2
✓ Branch 0 taken 3379712 times.
✓ Branch 1 taken 86016 times.
3465728 if(!firstx)
3664 3379712 si += fuzz;
3665 else
3666 {
3667 86016 si += fuzz-xstep;
3668 86016 firstx = 0;
3669 }
3670
3671 3465728 i = 0;
3672 3465728 }
3673 22020096 }
3674 86016 }
3675
3676
2/2
✓ Branch 0 taken 13472 times.
✓ Branch 1 taken 384 times.
13856 if(!firsty)
3677 13472 y += fuzz;
3678 else
3679 {
3680 384 y += ystep;
3681 384 ystep = fuzz;
3682 384 firsty = 0;
3683 }
3684 }
3685 384 }
3686
3687 3061096 void updatescr(bool allowwavy)
3688 {
3689
4/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3061085 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
3061096 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3690
4/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3061085 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
3061096 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3691
3692
1/2
✓ Branch 0 taken 3061096 times.
✗ Branch 1 not taken.
3061096 if(toogam)
3693 {
3694 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3695 }
3696
3697
1/2
✓ Branch 0 taken 3061096 times.
✗ Branch 1 not taken.
3061096 if(Showpal)
3698 dump_pal(framebuf);
3699
3700
2/2
✓ Branch 0 taken 3040634 times.
✓ Branch 1 taken 20462 times.
3061096 if(!Playing)
3701 20462 black_opening_count=0;
3702
3703
2/2
✓ Branch 0 taken 3045652 times.
✓ Branch 1 taken 15444 times.
3061096 if(black_opening_count<0) //shape is opening up
3704 {
3705 15444 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3706
3707
2/4
✓ Branch 0 taken 15444 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15444 times.
15444 if(Advance||(!Paused))
3708 {
3709 15444 ++black_opening_count;
3710 15444 }
3711 15444 }
3712
2/2
✓ Branch 0 taken 3038392 times.
✓ Branch 1 taken 7260 times.
3045652 else if(black_opening_count>0) //shape is closing
3713 {
3714 7260 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3715
3716
2/4
✓ Branch 0 taken 7260 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7260 times.
7260 if(Advance||(!Paused))
3717 {
3718 7260 --black_opening_count;
3719 7260 }
3720 7260 }
3721
3722
3/4
✓ Branch 0 taken 3038736 times.
✓ Branch 1 taken 22360 times.
✓ Branch 2 taken 3038736 times.
✗ Branch 3 not taken.
3061096 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3723 {
3724 black_opening_shape = bosCIRCLE;
3725 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3726 refreshTints();
3727 refreshpal=true;
3728 }
3729
3730
2/2
✓ Branch 0 taken 2960785 times.
✓ Branch 1 taken 100311 times.
3061096 if(refreshpal)
3731 {
3732 100311 refreshpal=false;
3733 100311 RAMpal[253] = _RGB(0,0,0);
3734 100311 RAMpal[254] = _RGB(63,63,63);
3735 100311 hw_palette = &RAMpal;
3736 100311 update_hw_pal = true;
3737
3738 100311 create_rgb_table(&rgb_table, RAMpal, NULL);
3739 100311 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3740 100311 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3741
3742
2/2
✓ Branch 0 taken 25679616 times.
✓ Branch 1 taken 100311 times.
25779927 for(int32_t q=0; q<PAL_SIZE; q++)
3743 {
3744 25679616 trans_table2.data[0][q] = q;
3745 25679616 trans_table2.data[q][q] = q;
3746 25679616 }
3747 100311 }
3748
3749 3061096 bool clearwavy = (wavy <= 0);
3750
3751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061096 times.
3061096 if(wavy <= 0)
3752 {
3753 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3754 3061096 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3755 3061096 }
3756
3757 3061096 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3758
3759
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3061096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3061096 if(wavy && Playing && allowwavy)
3760 {
3761 draw_wavy(framebuf, wavybuf, wavy,false);
3762 }
3763
3764
1/2
✓ Branch 0 taken 3061096 times.
✗ Branch 1 not taken.
3061096 if(clearwavy)
3765 3061096 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3766 else if(Playing && !Paused)
3767 wavy--; // Wavy was set by a script. Decrement it.
3768
3769
5/6
✓ Branch 0 taken 3040634 times.
✓ Branch 1 taken 20462 times.
✓ Branch 2 taken 57348 times.
✓ Branch 3 taken 2983286 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 57348 times.
3061096 if(Playing && msgpos && !screenscrolling)
3770 {
3771
1/2
✓ Branch 0 taken 57348 times.
✗ Branch 1 not taken.
57348 if(!(msg_bg_display_buf->clip))
3772 57348 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3773
1/2
✓ Branch 0 taken 57348 times.
✗ Branch 1 not taken.
57348 if(!(msg_portrait_display_buf->clip))
3774 57348 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3775
1/2
✓ Branch 0 taken 57348 times.
✗ Branch 1 not taken.
57348 if(!(msg_txt_display_buf->clip))
3776 57348 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3777 57348 }
3778
3779 /*
3780 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3781 {
3782 BITMAP* subBmp = 0;
3783 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3784 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3785 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3786 destroy_bitmap(subBmp);
3787 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3788 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3789 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3790 }
3791 */
3792
3793
2/2
✓ Branch 0 taken 3057051 times.
✓ Branch 1 taken 4045 times.
3061096 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3794
3795
2/2
✓ Branch 0 taken 3057051 times.
✓ Branch 1 taken 4045 times.
3061096 if(nosubscr)
3796 {
3797 4045 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3798 4045 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3799 4045 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3800 4045 }
3801
3802 //TODO: Optimize blit 'overcalls' -Gleeok
3803
2/2
✓ Branch 0 taken 4045 times.
✓ Branch 1 taken 3057051 times.
3061096 BITMAP *source = nosubscr ? panorama : wavybuf;
3804 3061096 blit(source,framebuf,0,0,0,0,256,224);
3805
3806 3061096 update_hw_screen();
3807 3061096 }
3808
3809 //----------------------------------------------------------------
3810
3811 PALETTE sys_pal;
3812
3813 int32_t onGUISnapshot()
3814 {
3815 char buf[200];
3816 int32_t num=0;
3817 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3818 do
3819 {
3820 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3821 }
3822 while(num<99999 && exists(buf));
3823
3824 BITMAP *b = create_bitmap_ex(8,resx,resy);
3825
3826 if(b)
3827 {
3828 if(MenuOpen)
3829 {
3830 //Cannot load game's palette while GUI elements are in focus. -Z
3831 //If there is a way to do this, then I have missed it.
3832 /*
3833 game_pal();
3834 RAMpal[253] = _RGB(0,0,0);
3835 RAMpal[254] = _RGB(63,63,63);
3836 set_palette_range(RAMpal,0,255,false);
3837 memcpy(RAMpal, snappal, sizeof(snappal));
3838 create_rgb_table(&rgb_table, RAMpal, NULL);
3839 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3840 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3841
3842 for(int32_t q=0; q<PAL_SIZE; q++)
3843 {
3844 trans_table2.data[0][q] = q;
3845 trans_table2.data[q][q] = q;
3846 }
3847 */
3848 //ringcolor(false);
3849 //get_palette(RAMpal);
3850 blit(screen,b,0,0,0,0,resx,resy);
3851 //al_trace("Menu Open\n");
3852 //game_pal();
3853 //PALETTE temppal;
3854 //get_palette(temppal);
3855 //system_pal();
3856 save_bitmap(buf,b,sys_pal);
3857 //save_bitmap(buf,b,RAMpal);
3858 //save_bitmap(buf,b,snappal);
3859 }
3860 else
3861 {
3862 blit(screen,b,0,0,0,0,resx,resy);
3863 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3864 }
3865 destroy_bitmap(b);
3866 }
3867
3868 return D_O_K;
3869 }
3870
3871 int32_t onNonGUISnapshot()
3872 {
3873 PALETTE temppal;
3874 get_palette(temppal);
3875 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3876
3877 char buf[200];
3878 int32_t num=0;
3879
3880 do
3881 {
3882 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3883 }
3884 while(num<99999 && exists(buf));
3885
3886 BITMAP *panorama = create_bitmap_ex(8,256,168);
3887 /*
3888 PALETTE tempRAMpal;
3889 get_palette(tempRAMpal);
3890
3891 if(tmpscr->flags3&fNOSUBSCR)
3892 {
3893 clear_to_color(panorama,0);
3894 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3895 save_bitmap(buf,panorama,realpal?temppal:tempRAMpal);
3896 }
3897 else
3898 {
3899 save_bitmap(buf,framebuf,realpal?temppal:tempRAMpal);
3900 }
3901
3902 destroy_bitmap(panorama);
3903 return D_O_K;
3904 */
3905 if(tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3906 {
3907 clear_to_color(panorama,0);
3908 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3909 save_bitmap(buf,panorama,realpal?temppal:RAMpal);
3910 }
3911 else
3912 {
3913 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3914 }
3915
3916 destroy_bitmap(panorama);
3917 return D_O_K;
3918 }
3919
3920 int32_t onSnapshot()
3921 {
3922 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3923 {
3924 onGUISnapshot();
3925 }
3926 else
3927 {
3928 onNonGUISnapshot();
3929 }
3930
3931 return D_O_K;
3932 }
3933
3934 int32_t onSaveMapPic()
3935 {
3936 int32_t mapres2 = 0;
3937 char buf[200];
3938 int32_t num=0;
3939 mapscr tmpscr_b[2];
3940 mapscr tmpscr_c[6];
3941 BITMAP* _screen_draw_buffer = NULL;
3942 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3943 set_clip_state(_screen_draw_buffer,1);
3944
3945 for(int32_t i=0; i<6; ++i)
3946 {
3947 tmpscr_c[i] = tmpscr2[i];
3948 tmpscr2[i].zero_memory();
3949
3950 if(i>=2)
3951 {
3952 continue;
3953 }
3954
3955 tmpscr_b[i] = tmpscr[i];
3956 tmpscr[i].zero_memory();
3957 }
3958
3959 do
3960 {
3961 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3962 }
3963 while(num<99999 && exists(buf));
3964
3965 BITMAP* mappic = NULL;
3966
3967
3968 bool done=false, redraw=true;
3969
3970 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3971
3972 if(!mappic)
3973 {
3974 system_pal();
3975 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
3976 game_pal();
3977 return D_O_K;;
3978 }
3979
3980 // draw the map
3981 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3982
3983 for(int32_t y=0; y<8; y++)
3984 {
3985 for(int32_t x=0; x<16; x++)
3986 {
3987 if(!displayOnMap(x, y))
3988 {
3989 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3990 }
3991 else
3992 {
3993 int32_t s = (y<<4) + x;
3994 loadscr2(1,s,-1);
3995
3996 for(int32_t i=0; i<6; i++)
3997 {
3998 if(tmpscr[1].layermap[i]<=0)
3999 continue;
4000
4001 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4002 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4003 {
4004 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4005
4006 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4007 }
4008 }
4009
4010 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4011
4012 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4013
4014 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4015 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4016
4017 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4018
4019 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4020 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4021 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4022 {
4023 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4024 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4025 }
4026 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4027
4028 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4029
4030 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4031 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4032 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4033 {
4034 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4035 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4036 }
4037 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4038 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4039
4040 }
4041
4042 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4043 }
4044 }
4045
4046 for(int32_t i=0; i<6; ++i)
4047 {
4048 tmpscr2[i]=tmpscr_c[i];
4049
4050 if(i>=2)
4051 {
4052 continue;
4053 }
4054
4055 tmpscr[i]=tmpscr_b[i];
4056 }
4057
4058 save_bitmap(buf,mappic,RAMpal);
4059 destroy_bitmap(mappic);
4060 destroy_bitmap(_screen_draw_buffer);
4061 return D_O_K;
4062 }
4063
4064 /*
4065 int32_t onSaveMapPic()
4066 {
4067 BITMAP* mappic = NULL;
4068 BITMAP* _screen_draw_buffer = NULL;
4069 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4070 int32_t mapres2 = 0;
4071 char buf[20];
4072 int32_t num=0;
4073 set_clip_state(_screen_draw_buffer,1);
4074 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4075
4076 do
4077 {
4078 sprintf(buf, "zelda%03d.png", ++num);
4079 }
4080 while(num<999 && exists(buf));
4081
4082 // if(!mappic) {
4083 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4084
4085 if(!mappic)
4086 {
4087 system_pal();
4088 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4089 game_pal();
4090 return D_O_K;
4091 }
4092
4093 // }
4094
4095 int32_t layermap, layerscreen;
4096 int32_t x2=0;
4097
4098 // draw the map
4099 for(int32_t y=0; y<8; y++)
4100 {
4101 for(int32_t x=0; x<16; x++)
4102 {
4103 int32_t s = (y<<4) + x;
4104
4105 if(!displayOnMap(x, y))
4106 {
4107 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4108 }
4109 else
4110 {
4111 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4112 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4113
4114 for(int32_t k=0; k<4; k++)
4115 {
4116 if(k==2)
4117 {
4118 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4119 }
4120
4121 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4122
4123 if(layermap>-1)
4124 {
4125 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4126
4127 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4128 {
4129 for(int32_t i=0; i<176; i++)
4130 {
4131 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4132 }
4133 }
4134 else
4135 {
4136 for(int32_t i=0; i<176; i++)
4137 {
4138 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4139 }
4140 }
4141 }
4142 }
4143
4144 for(int32_t i=0; i<176; i++)
4145 {
4146 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4147 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4148 {
4149 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4150 }
4151 }
4152
4153 for(int32_t k=4; k<6; k++)
4154 {
4155 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4156
4157 if(layermap>-1)
4158 {
4159 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4160
4161 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4162 {
4163 for(int32_t i=0; i<176; i++)
4164 {
4165 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4166 }
4167 }
4168 else
4169 {
4170 for(int32_t i=0; i<176; i++)
4171 {
4172 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4173 }
4174 }
4175 }
4176 }
4177 }
4178
4179 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4180 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4181 }
4182
4183 }
4184
4185 save_bitmap(buf,mappic,RAMpal);
4186 destroy_bitmap(mappic);
4187 destroy_bitmap(_screen_draw_buffer);
4188 return D_O_K;
4189 }
4190 */
4191
4192 1 void f_Quit(int32_t type)
4193 {
4194
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(type==qQUIT && !Playing)
4195 return;
4196
4197 1 bool from_menu = is_sys_pal;
4198
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!from_menu)
4200 {
4201 1 music_pause();
4202 1 pause_all_sfx();
4203 1 }
4204 1 enter_sys_pal();
4205 1 clear_keybuf();
4206
4207 1 replay_poll();
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (replay_is_replaying())
4209 1 replay_peek_quit();
4210
4211
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!replay_is_replaying())
4212 switch(type)
4213 {
4214 case qQUIT:
4215 onQuit();
4216 break;
4217
4218 case qRESET:
4219 onReset();
4220 break;
4221
4222 case qEXIT:
4223 onExit();
4224 break;
4225 }
4226
4227
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(Quit)
4228 {
4229 1 kill_sfx();
4230 1 music_stop();
4231 1 exit_sys_pal();
4232 1 update_hw_screen();
4233 1 }
4234 else
4235 {
4236 exit_sys_pal();
4237 if(!from_menu)
4238 {
4239 music_resume();
4240 resume_all_sfx();
4241 }
4242 }
4243
4244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!from_menu)
4245 1 show_mouse(NULL);
4246 1 eat_buttons();
4247
4248 1 zc_readrawkey(KEY_ESC);
4249
4250 1 zc_readrawkey(KEY_ENTER);
4251 1 }
4252
4253 //----------------------------------------------------------------
4254
4255 int32_t onNoWalls()
4256 {
4257 cheats_enqueue(Cheat::Walls);
4258 return D_O_K;
4259 }
4260
4261 int32_t onIgnoreSideview()
4262 {
4263 cheats_enqueue(Cheat::IgnoreSideView);
4264 return D_O_K;
4265 }
4266
4267 3108180 int32_t input_idle(bool checkmouse)
4268 {
4269 static int32_t mx, my, mz, mb;
4270
4271
4/6
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 586494 times.
✓ Branch 3 taken 2521686 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 586494 times.
3694674 if(keypressed() || zc_key_pressed() ||
4272
4/8
✓ Branch 0 taken 586494 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 586494 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 586494 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 586494 times.
✗ Branch 7 not taken.
586494 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4273 {
4274 2521686 idle_count = 0;
4275
4276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2521686 times.
2521686 if(active_count < MAX_ACTIVE)
4277 {
4278 2521686 ++active_count;
4279 2521686 }
4280 2521686 }
4281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586494 times.
586494 else if(idle_count < MAX_IDLE)
4282 {
4283 586494 ++idle_count;
4284 586494 active_count = 0;
4285 586494 }
4286
4287 3108180 mx = mouse_x;
4288 3108180 my = mouse_y;
4289 3108180 mz = mouse_z;
4290 3108180 mb = mouse_b;
4291
4292 3108180 return idle_count;
4293 }
4294
4295 int32_t onGoFast()
4296 {
4297 cheats_enqueue(Cheat::Fast);
4298 return D_O_K;
4299 }
4300
4301 int32_t onKillCheat()
4302 {
4303 cheats_enqueue(Cheat::Kill);
4304 return D_O_K;
4305 }
4306
4307 int32_t onShowLayer0()
4308 {
4309 show_layer_0 = !show_layer_0;
4310 return D_O_K;
4311 }
4312 int32_t onShowLayer1()
4313 {
4314 show_layer_1 = !show_layer_1;
4315 return D_O_K;
4316 }
4317 int32_t onShowLayer2()
4318 {
4319 show_layer_2 = !show_layer_2;
4320 return D_O_K;
4321 }
4322 int32_t onShowLayer3()
4323 {
4324 show_layer_3 = !show_layer_3;
4325 return D_O_K;
4326 }
4327 int32_t onShowLayer4()
4328 {
4329 show_layer_4 = !show_layer_4;
4330 return D_O_K;
4331 }
4332 int32_t onShowLayer5()
4333 {
4334 show_layer_5 = !show_layer_5;
4335 return D_O_K;
4336 }
4337 int32_t onShowLayer6()
4338 {
4339 show_layer_6 = !show_layer_6;
4340 return D_O_K;
4341 }
4342 int32_t onShowLayerO()
4343 {
4344 show_layer_over=!show_layer_over;
4345 return D_O_K;
4346 }
4347 int32_t onShowLayerP()
4348 {
4349 show_layer_push=!show_layer_push;
4350 return D_O_K;
4351 }
4352 int32_t onShowLayerS()
4353 {
4354 show_sprites=!show_sprites;
4355 return D_O_K;
4356 }
4357 int32_t onShowLayerF()
4358 {
4359 show_ffcs=!show_ffcs;
4360 return D_O_K;
4361 }
4362 int32_t onShowLayerW()
4363 {
4364 show_walkflags=!show_walkflags;
4365 return D_O_K;
4366 }
4367 int32_t onShowLayerE()
4368 {
4369 show_effectflags=!show_effectflags;
4370 return D_O_K;
4371 }
4372 int32_t onShowFFScripts()
4373 {
4374 show_ff_scripts=!show_ff_scripts;
4375 return D_O_K;
4376 }
4377 int32_t onShowHitboxes()
4378 {
4379 show_hitboxes=!show_hitboxes;
4380 return D_O_K;
4381 }
4382
4383 int32_t onLightSwitch()
4384 {
4385 cheats_enqueue(Cheat::Light);
4386 return D_O_K;
4387 }
4388
4389 int32_t onGoTo();
4390 int32_t onGoToComplete();
4391
4392 3108180 void syskeys()
4393 {
4394 3108180 update_system_keys();
4395
4396 int32_t oldtitle_version;
4397
4398
1/2
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
3108180 if(close_button_quit)
4399 {
4400 close_button_quit=false;
4401 f_Quit(qEXIT);
4402 }
4403
4404 3108180 poll_joystick();
4405
4406
2/10
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3108180 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3108180 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4407 {
4408 oldtitle_version=title_version;
4409 System();
4410 }
4411
4412 3108180 mouse_down=gui_mouse_b();
4413
4414
1/2
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
3108180 if(zc_read_system_key(KEY_F1))
4415 {
4416 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4417 {
4418 halt=!halt;
4419 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4420 }
4421 else
4422 {
4423 Throttlefps=!Throttlefps;
4424 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4425 logic_counter=0;
4426 }
4427 }
4428
4429 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4430 /*
4431 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4432 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4433 */
4434
4435
1/4
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3108180 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4436
4437
1/4
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3108180 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4438
4439
1/2
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
3108180 if(zc_read_system_key(KEY_F2))
4440 {
4441 ShowFPS=!ShowFPS;
4442 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4443 }
4444
4445
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3108180 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3108180 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4446
4447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3108180 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3108180 if(zc_read_system_key(KEY_F4) && Playing)
4448 {
4449 Paused=true;
4450 Advance=true;
4451 }
4452
4453
1/2
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
3108180 if(zc_read_system_key(KEY_F6)) onTryQuit();
4454
4455 #ifndef ALLEGRO_MACOSX
4456 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4457
4458 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4459 #else
4460
1/2
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
3108180 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4461
4462
1/2
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
3108180 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4463 #endif
4464
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3108180 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3108180 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4465
4466
1/2
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
3108180 if (zc_read_system_key(KEY_F12))
4467 {
4468 onSnapshot();
4469 }
4470
4471
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3108180 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3108180 if(debug_enabled && zc_read_system_key(KEY_TAB))
4472 set_debug(!get_debug());
4473
4474
3/4
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 3094337 times.
3108180 if(get_debug() || cheat>=1)
4475 {
4476
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4477 {
4478 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4479
4480 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4481
4482 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4483
4484 if(zc_readkey(KEY_B))
4485 {
4486 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4487 }
4488
4489 if(zc_readkey(KEY_A))
4490 {
4491 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4492 }
4493 }
4494 13843 }
4495
4496
3/4
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 3094337 times.
3108180 if(get_debug() || cheat>=2)
4497 {
4498
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4499 {
4500 if(rI())
4501 {
4502 cheats_enqueue(Cheat::Clock);
4503 }
4504 }
4505 13843 }
4506
4507
3/4
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 3094337 times.
3108180 if(get_debug() || cheat>=4)
4508 {
4509
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4510 {
4511 if(rF11())
4512 {
4513 cheats_enqueue(Cheat::Walls);
4514 }
4515
4516 if(rQ())
4517 {
4518 cheats_enqueue(Cheat::Fast);
4519 }
4520
4521 if(zc_readkey(KEY_F))
4522 {
4523 cheats_enqueue(Cheat::Freeze);
4524 }
4525
4526 if(zc_readkey(KEY_G)) onGoToComplete();
4527
4528 if(zc_readkey(KEY_0)) onShowLayer0();
4529
4530 if(zc_readkey(KEY_1)) onShowLayer1();
4531
4532 if(zc_readkey(KEY_2)) onShowLayer2();
4533
4534 if(zc_readkey(KEY_3)) onShowLayer3();
4535
4536 if(zc_readkey(KEY_4)) onShowLayer4();
4537
4538 if(zc_readkey(KEY_5)) onShowLayer5();
4539
4540 if(zc_readkey(KEY_6)) onShowLayer6();
4541
4542 //if(zc_readkey(KEY_7)) onShowLayerO();
4543 if(zc_readkey(KEY_7)) onShowLayerF();
4544
4545 if(zc_readkey(KEY_8)) onShowLayerS();
4546
4547 if(zc_readkey(KEY_W)) onShowLayerW();
4548
4549 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4550
4551 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4552
4553 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4554 if(zc_readkey(KEY_O)) onShowLayerO();
4555 if(zc_readkey(KEY_P)) onShowLayerP();
4556 if(zc_readkey(KEY_C)) onShowHitboxes();
4557 if(zc_readkey(KEY_F)) onShowFFScripts();
4558 }
4559 13843 }
4560
4561
1/2
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
3108180 if(volkeys)
4562 {
4563 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4564
4565 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4566
4567 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4568
4569 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4570 }
4571
4572
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3108180 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3108180 if(!get_debug() || !SystemKeys || replay_is_replaying())
4573 3108180 goto bottom;
4574
4575 if(zc_readkey(KEY_D))
4576 {
4577 details = !details;
4578 rectfill(screen,0,0,319,7,BLACK);
4579 rectfill(screen,0,8,31,239,BLACK);
4580 rectfill(screen,288,8,319,239,BLACK);
4581 rectfill(screen,32,232,287,239,BLACK);
4582 }
4583
4584 if(zc_readkey(KEY_P)) Paused=!Paused;
4585
4586 //if(zc_readkey(KEY_P)) centerHero();
4587 if(zc_readkey(KEY_A))
4588 {
4589 Paused=true;
4590 Advance=true;
4591 }
4592
4593 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4594 #ifndef ALLEGRO_MACOSX
4595 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4596
4597 if(zc_readkey(KEY_F7))
4598 {
4599 Matrix(ss_speed, ss_density, 0);
4600 game_pal();
4601 }
4602 #else
4603 // The reason these are different on Mac in the first place is that
4604 // the OS doesn't let us use F9 and F10...
4605 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4606
4607 if(zc_readkey(KEY_F9))
4608 {
4609 Matrix(ss_speed, ss_density, 0);
4610 game_pal();
4611 }
4612 #endif
4613 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4614 {
4615 //change containers
4616 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4617 {
4618 //magic containers
4619 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4620 {
4621 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4622 }
4623 else
4624 {
4625 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4626 }
4627 }
4628 else
4629 {
4630 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4631 {
4632 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4633 }
4634 else
4635 {
4636 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4637 }
4638 }
4639 }
4640
4641 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4642 {
4643 //change containers
4644 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4645 {
4646 //magic containers
4647 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4648 {
4649 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4650 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4651 //heart containers
4652 }
4653 else
4654 {
4655 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4656 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4657 }
4658 }
4659 else
4660 {
4661 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4662 {
4663 game->set_magic(zc_max(game->get_magic()-1,0));
4664 }
4665 else
4666 {
4667 game->set_life(zc_max(game->get_life()-1,0));
4668 }
4669 }
4670 }
4671
4672 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4673
4674 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4675
4676 verifyBothWeapons();
4677
4678 bottom:
4679
4680
1/2
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
3108180 if(input_idle(true) > after_time())
4681 {
4682 Matrix(ss_speed, ss_density, 0);
4683 game_pal();
4684 }
4685 //Saffith's method of separating system and game key bindings. Can't do this!!
4686 //restoreInput(); //This caused input to become randomly 'stuck'. -Z
4687
4688 //while(Playing && keypressed())
4689 //readkey();
4690 // What's the Playing check for?
4691 3108180 clear_keybuf();
4692 3108180 }
4693
4694 1968153 void checkQuitKeys()
4695 {
4696 #ifndef ALLEGRO_MACOSX
4697 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4698
4699 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4700 #else
4701
1/2
✓ Branch 0 taken 1968153 times.
✗ Branch 1 not taken.
1968153 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4702
4703
1/2
✓ Branch 0 taken 1968153 times.
✗ Branch 1 not taken.
1968153 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4704 #endif
4705 1968153 }
4706
4707 41529 bool CheatModifierKeys()
4708 {
4709 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4710 // to trigger cheats.
4711
1/2
✓ Branch 0 taken 41529 times.
✗ Branch 1 not taken.
41529 if (replay_is_replaying())
4712 41529 return false;
4713
4714 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4715 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4716 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4717 {
4718 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4719 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4720 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4721 {
4722 return true;
4723 }
4724 }
4725 return false;
4726 41529 }
4727
4728 //99:05:54, for some reason?
4729 #define OLDMAXTIME 21405240
4730 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4731 #define MAXTIME 1944000000
4732
4733 3061111 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4734 {
4735
2/2
✓ Branch 0 taken 2812117 times.
✓ Branch 1 taken 248994 times.
3061111 if(zcmusic!=NULL)
4736 {
4737 248994 zcmusic_poll();
4738 248994 }
4739
4740
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3061111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3061111 times.
3061111 while(Paused && !Advance && !Quit)
4741 {
4742 // have to call this, otherwise we'll get an infinite loop
4743 syskeys();
4744 if(allowF6Script)
4745 {
4746 FFCore.runF6Engine();
4747 }
4748 if (replay_get_mode() != ReplayMode::Assert)
4749 updatescr(allowwavy);
4750 throttleFPS();
4751
4752 #ifdef _WIN32
4753
4754 if(use_dwm_flush)
4755 {
4756 do_DwmFlush();
4757 }
4758
4759 #endif
4760
4761 // to keep music playing
4762 if(zcmusic!=NULL)
4763 {
4764 zcmusic_poll();
4765 }
4766
4767 update_hw_screen();
4768 }
4769
4770
2/2
✓ Branch 0 taken 3061098 times.
✓ Branch 1 taken 13 times.
3061111 if(Quit)
4771 13 return;
4772
4773
3/4
✓ Branch 0 taken 3040635 times.
✓ Branch 1 taken 20463 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3040635 times.
3061098 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4774 3040635 game->change_time(1);
4775
4776 3061098 Advance=false;
4777
4778
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3061096 times.
3061098 if (replay_is_active())
4779 {
4780
2/2
✓ Branch 0 taken 1270461 times.
✓ Branch 1 taken 1790635 times.
3061096 if (replay_get_version() >= 3)
4781 1790635 replay_poll();
4782
2/2
✓ Branch 0 taken 3050343 times.
✓ Branch 1 taken 10753 times.
3061096 if (replay_get_version() >= 6)
4783 10753 replay_peek_input();
4784 3061096 }
4785 3061098 update_keys();
4786
4787 3061098 ++frame;
4788
4789
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3061096 times.
3061098 if (replay_is_replaying())
4790 3061096 replay_do_cheats();
4791 3061098 syskeys();
4792
4793 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4794 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4795 // approach here means it doesn't matter which call adds the cheat.
4796 3061098 cheats_execute_queued();
4797
4798
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3061096 times.
3061098 if (replay_is_replaying())
4799 3061096 replay_peek_quit();
4800
2/2
✓ Branch 0 taken 3061097 times.
✓ Branch 1 taken 1 times.
3061098 if (GameFlags & GAMEFLAG_TRYQUIT)
4801 1 replay_step_quit(0);
4802
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 3060366 times.
3061098 if(allowF6Script)
4803 {
4804 3060366 FFCore.runF6Engine();
4805 3060366 }
4806
2/2
✓ Branch 0 taken 3061013 times.
✓ Branch 1 taken 85 times.
3061098 if (Quit)
4807 85 replay_step_quit(Quit);
4808 // Someday... maybe install a Turbo button here?
4809 3061098 updatescr(allowwavy);
4810 3061098 throttleFPS();
4811
4812 #ifdef _WIN32
4813
4814 if(use_dwm_flush)
4815 {
4816 do_DwmFlush();
4817 }
4818
4819 #endif
4820
4821 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4822
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 3060800 times.
3061098 if(sfxcleanup)
4823 3060800 sfx_cleanup();
4824 3061111 }
4825
4826 8 void zapout()
4827 {
4828 8 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4829 8 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4830
4831 8 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4832 8 script_drawing_commands.Clear();
4833
4834 // zap out
4835
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 192 times.
200 for(int32_t i=1; i<=24; i++)
4836 {
4837 192 draw_fuzzy(i);
4838 192 syskeys();
4839 192 advanceframe(true);
4840
4841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(Quit)
4842 {
4843 break;
4844 }
4845 192 }
4846 8 }
4847
4848 8 void zapin()
4849 {
4850 8 FFCore.warpScriptCheck();
4851 8 draw_screen(tmpscr);
4852 8 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4853 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4854 8 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4855
4856 // zap out
4857 8 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4858
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 192 times.
200 for(int32_t i=24; i>=1; i--)
4859 {
4860 192 draw_fuzzy(i);
4861 192 syskeys();
4862 192 advanceframe(true);
4863
4864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(Quit)
4865 {
4866 break;
4867 }
4868 192 }
4869 8 }
4870
4871
4872 void wavyout(bool showhero)
4873 {
4874 draw_screen(tmpscr, showhero);
4875 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4876
4877 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4878 clear_to_color(wavebuf,0);
4879 blit(framebuf,wavebuf,0,0,16,0,256,224);
4880
4881 static PALETTE wavepal;
4882
4883 int32_t ofs;
4884 int32_t amplitude=8;
4885
4886 int32_t wavelength=4;
4887 double palpos=0, palstep=4, palstop=126;
4888
4889 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4890 for(int32_t i=0; i<168; i+=wavelength)
4891 {
4892 for(int32_t l=0; l<256; l++)
4893 {
4894 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4895 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4896 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4897 }
4898
4899 palpos+=palstep;
4900
4901 if(palpos>=0)
4902 {
4903 hw_palette = &wavepal;
4904 update_hw_pal = true;
4905 }
4906 else
4907 {
4908 hw_palette = &RAMpal;
4909 update_hw_pal = true;
4910 }
4911
4912 for(int32_t j=0; j+playing_field_offset<224; j++)
4913 {
4914 for(int32_t k=0; k<256; k++)
4915 {
4916 ofs=0;
4917
4918 if((j<i)&&(j&1))
4919 {
4920 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4921 }
4922
4923 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4924 }
4925 }
4926
4927 syskeys();
4928 advanceframe(true);
4929
4930 // animate_combos();
4931 if(Quit)
4932 break;
4933 }
4934
4935 destroy_bitmap(wavebuf);
4936 }
4937
4938 void wavyin()
4939 {
4940 draw_screen(tmpscr);
4941 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4942
4943 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4944 clear_to_color(wavebuf,0);
4945 blit(framebuf,wavebuf,0,0,16,0,256,224);
4946
4947 static PALETTE wavepal;
4948
4949 //Breaks dark rooms.
4950 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4951 /*
4952 loadfullpal();
4953 loadlvlpal(DMaps[currdmap].color);
4954 ringcolor(false);
4955 */
4956 refreshpal=false;
4957 int32_t ofs;
4958 int32_t amplitude=8;
4959 int32_t wavelength=4;
4960 double palpos=168, palstep=4, palstop=126;
4961
4962 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4963 for(int32_t i=0; i<168; i+=wavelength)
4964 {
4965 for(int32_t l=0; l<256; l++)
4966 {
4967 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4968 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4969 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4970 }
4971
4972 palpos-=palstep;
4973
4974 if(palpos>=0)
4975 {
4976 hw_palette = &wavepal;
4977 update_hw_pal = true;
4978 }
4979 else
4980 {
4981 hw_palette = &RAMpal;
4982 update_hw_pal = true;
4983 }
4984
4985 for(int32_t j=0; j+playing_field_offset<224; j++)
4986 {
4987 for(int32_t k=0; k<256; k++)
4988 {
4989 ofs=0;
4990
4991 if((j<(167-i))&&(j&1))
4992 {
4993 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4994 }
4995
4996 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4997 }
4998 }
4999
5000 syskeys();
5001 advanceframe(true);
5002 // animate_combos();
5003
5004 if(Quit)
5005 break;
5006 }
5007
5008 destroy_bitmap(wavebuf);
5009 }
5010
5011 998 void blackscr(int32_t fcnt,bool showsubscr)
5012 {
5013 998 reset_pal_cycling();
5014 998 script_drawing_commands.Clear();
5015
5016 998 FFCore.warpScriptCheck();
5017 998 bool showtime = game->should_show_time();
5018
2/2
✓ Branch 0 taken 998 times.
✓ Branch 1 taken 29884 times.
30882 while(fcnt>0)
5019 {
5020 29884 clear_bitmap(framebuf);
5021
5022
2/2
✓ Branch 0 taken 8130 times.
✓ Branch 1 taken 21754 times.
29884 if(showsubscr)
5023 {
5024 21754 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5025
3/4
✓ Branch 0 taken 21754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 21724 times.
21754 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5026 {
5027 30 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5028 30 }
5029 21754 }
5030
5031 29884 syskeys();
5032 29884 advanceframe(true);
5033
5034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29884 times.
29884 if(Quit)
5035 break;
5036
5037 29884 --fcnt;
5038 }
5039 998 }
5040
5041 234 void openscreen(int32_t shape)
5042 {
5043 234 reset_pal_cycling();
5044 234 black_opening_count=0;
5045
5046
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 136 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
234 if(COOLSCROLL || shape>-1)
5047 {
5048 136 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5049 136 return;
5050 }
5051 else
5052 {
5053 98 Hero.setDontDraw(true);
5054 98 show_subscreen_dmap_dots=false;
5055 98 show_subscreen_numbers=false;
5056 // show_subscreen_items=false;
5057 98 show_subscreen_life=false;
5058 }
5059
5060 98 int32_t x=128;
5061
5062 98 FFCore.warpScriptCheck();
5063
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5064 {
5065 7840 draw_screen(tmpscr);
5066 //? draw_screen already draws the subscreen -DD
5067 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5068 7840 x=128-(((i*128/80)/8)*8);
5069
5070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5071 {
5072 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5073 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5074 7840 }
5075
5076 // x=((80-i)/2)*4;
5077 /*
5078 --x;
5079 switch(++c)
5080 {
5081 case 5: c=0;
5082 case 0:
5083 case 2:
5084 case 3: --x; break;
5085 }
5086 */
5087 7840 syskeys();
5088 7840 advanceframe(true);
5089
5090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5091 {
5092 break;
5093 }
5094 7840 }
5095
5096 98 Hero.setDontDraw(false);
5097 98 show_subscreen_items=true;
5098 98 show_subscreen_dmap_dots=true;
5099 234 }
5100
5101 void closescreen(int32_t shape)
5102 {
5103 reset_pal_cycling();
5104 black_opening_count=0;
5105
5106 if(COOLSCROLL || shape>-1)
5107 {
5108 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5109 return;
5110 }
5111 else
5112 {
5113 Hero.setDontDraw(true);
5114 show_subscreen_dmap_dots=false;
5115 show_subscreen_numbers=false;
5116 // show_subscreen_items=false;
5117 show_subscreen_life=false;
5118 }
5119
5120 int32_t x=128;
5121
5122 FFCore.warpScriptCheck();
5123 for(int32_t i=79; i>=0; --i)
5124 {
5125 draw_screen(tmpscr);
5126 //? draw_screen already draws the subscreen -DD
5127 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5128 x=128-(((i*128/80)/8)*8);
5129
5130 if(x>0)
5131 {
5132 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5133 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5134 }
5135
5136 // x=((80-i)/2)*4;
5137 /*
5138 --x;
5139 switch(++c)
5140 {
5141 case 5: c=0;
5142 case 0:
5143 case 2:
5144 case 3: --x; break;
5145 }
5146 */
5147 syskeys();
5148 advanceframe(true);
5149
5150 if(Quit)
5151 {
5152 break;
5153 }
5154 }
5155
5156 Hero.setDontDraw(false);
5157 show_subscreen_items=true;
5158 show_subscreen_dmap_dots=true;
5159 }
5160
5161 70 int32_t TriforceCount()
5162 {
5163 70 int32_t c=0;
5164
5165
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 70 times.
630 for(int32_t i=1; i<=8; i++)
5166
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 317 times.
877 if(game->lvlitems[i]&liTRIFORCE)
5167 317 ++c;
5168
5169 70 return c;
5170 }
5171
5172 int32_t onCustomGame()
5173 {
5174 int32_t file = getsaveslot();
5175
5176 if(file < 0)
5177 return D_O_K;
5178
5179 bool ret = (custom_game(file)!=0);
5180 return ret ? D_CLOSE : D_O_K;
5181 }
5182
5183 int32_t onContinue()
5184 {
5185 return D_CLOSE;
5186 }
5187
5188 int32_t onEsc() // Unused?? -L
5189 {
5190 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5191 }
5192
5193 int32_t onVsync()
5194 {
5195 Throttlefps = !Throttlefps;
5196 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5197 return D_O_K;
5198 }
5199
5200 int32_t onWinPosSave()
5201 {
5202 SaveWinPos = !SaveWinPos;
5203 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5204 return D_O_K;
5205 }
5206
5207 int32_t onClickToFreeze()
5208 {
5209 ClickToFreeze = !ClickToFreeze;
5210 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5211 return D_O_K;
5212 }
5213
5214 int32_t OnSaveZCConfig()
5215 {
5216 if(jwin_alert3(
5217 "Save Configuration",
5218 "Are you sure that you wish to save your present configuration settings?",
5219 "This will overwrite your prior settings!",
5220 NULL,
5221 "&Yes",
5222 "&No",
5223 NULL,
5224 'y',
5225 'n',
5226 0,
5227 lfont) == 1)
5228 {
5229 save_game_configs();
5230 return D_O_K;
5231 }
5232 else return D_O_K;
5233 }
5234
5235 int32_t OnnClearQuestDir()
5236 {
5237 if(jwin_alert3(
5238 "Clear Current Directory Cache",
5239 "Are you sure that you wish to clear the current cached directory?",
5240 "This will default the current directory to the ROOT for this instance of ZC Player!",
5241 NULL,
5242 "&Yes",
5243 "&No",
5244 NULL,
5245 'y',
5246 'n',
5247 0,
5248 lfont) == 1)
5249 {
5250 zc_set_config("zeldadx","win_qst_dir","");
5251 flush_config_file();
5252 strcpy(qstdir,"");
5253 #ifdef __EMSCRIPTEN__
5254 em_sync_fs();
5255 #endif
5256 return D_O_K;
5257 }
5258 else return D_O_K;
5259 }
5260
5261
5262 int32_t onConsoleZASM()
5263 {
5264 if ( !zasm_debugger )
5265 {
5266 AlertDialog("WARNING: ZASM Debugger",
5267 "Enabling this will open the ZASM Debugger Console"
5268 "\nThis will likely grind ZC to a halt with lag."
5269 "\nTo make any use of this, it is suggested that you read"
5270 "\nthe documentation for 'void Breakpoint(char[] string);'"
5271 " in 'ZScript_Additions.txt'"
5272 "\nThis is not recommended for normal users,"
5273 " and is only intended for ZC developers,"
5274 "\nor quest developers coding directly in ZASM"
5275 "\nAre you sure that you wish to open the ZASM Debugger?",
5276 [&](bool ret,bool)
5277 {
5278 if(ret)
5279 {
5280 FFCore.ZASMPrint(true);
5281 }
5282 }).show();
5283 return D_O_K;
5284 }
5285 else
5286 {
5287 FFCore.ZASMPrint(false);
5288 return D_O_K;
5289 }
5290 }
5291
5292
5293 int32_t onConsoleZScript()
5294 {
5295 if ( !zscript_debugger )
5296 {
5297 AlertDialog("ZScript Debugger",
5298 "Enabling this will open the ZScript Debugger Console"
5299 "\nThis will display any messages logged by scripts,"
5300 " including script errors."
5301 "\nAre you sure that you wish to open the ZScript Debugger?",
5302 [&](bool ret,bool)
5303 {
5304 if(ret)
5305 {
5306 FFCore.ZScriptConsole(true);
5307 }
5308 }).show();
5309 return D_O_K;
5310 }
5311 else
5312 {
5313 FFCore.ZScriptConsole(false);
5314 return D_O_K;
5315 }
5316 }
5317
5318 int32_t onClrConsoleOnLoad()
5319 {
5320 clearConsoleOnLoad = !clearConsoleOnLoad;
5321 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5322 return D_O_K;
5323 }
5324
5325
5326 int32_t onFrameSkip()
5327 {
5328 FrameSkip = !FrameSkip;
5329 return D_O_K;
5330 }
5331
5332 int32_t onSaveDragResize()
5333 {
5334 SaveDragResize = !SaveDragResize;
5335 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5336 return D_O_K;
5337 }
5338
5339 int32_t onDragAspect()
5340 {
5341 DragAspect = !DragAspect;
5342 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5343 return D_O_K;
5344 }
5345
5346 int32_t onTransLayers()
5347 {
5348 TransLayers = !TransLayers;
5349 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5350 return D_O_K;
5351 }
5352
5353 int32_t onNESquit()
5354 {
5355 NESquit = !NESquit;
5356 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5357 return D_O_K;
5358 }
5359
5360 int32_t onVolKeys()
5361 {
5362 volkeys = !volkeys;
5363 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5364 return D_O_K;
5365 }
5366
5367 int32_t onShowFPS()
5368 {
5369 ShowFPS = !ShowFPS;
5370 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5371 return D_O_K;
5372 }
5373
5374 366765240 bool is_Fkey(int32_t k)
5375 {
5376
2/2
✓ Branch 0 taken 37298160 times.
✓ Branch 1 taken 329467080 times.
366765240 switch(k)
5377 {
5378 case KEY_F1:
5379 case KEY_F2:
5380 case KEY_F3:
5381 case KEY_F4:
5382 case KEY_F5:
5383 case KEY_F6:
5384 case KEY_F7:
5385 case KEY_F8:
5386 case KEY_F9:
5387 case KEY_F10:
5388 case KEY_F11:
5389 case KEY_F12:
5390 37298160 return true;
5391 }
5392
5393 329467080 return false;
5394 366765240 }
5395
5396 void kb_getkey(DIALOG *d)
5397 {
5398 d->flags|=D_SELECTED;
5399
5400 scare_mouse();
5401 jwin_button_proc(MSG_DRAW,d,0);
5402 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5403 // text_mode(vc(11));
5404 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5405 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5406 unscare_mouse();
5407
5408 update_hw_screen(true);
5409
5410 clear_keybuf();
5411 int32_t k = next_press_key();
5412 clear_keybuf();
5413
5414 //shnarf
5415 //47=f1
5416 //59=esc
5417 if(k>0 && k<123 && !((k>46)&&(k<60)))
5418 *((int32_t*)d->dp3) = k;
5419
5420
5421 d->flags&=~D_SELECTED;
5422 }
5423
5424
5425 //Used by all keyboard key settings dialogues.
5426 void kb_clearjoystick(DIALOG *d)
5427 {
5428 d->flags|=D_SELECTED;
5429
5430 scare_mouse();
5431 jwin_button_proc(MSG_DRAW,d,0);
5432 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5433 // text_mode(vc(11));
5434 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5435 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5436 unscare_mouse();
5437
5438 update_hw_screen(true);
5439
5440 clear_keybuf();
5441 int32_t k = next_press_key();
5442 clear_keybuf();
5443
5444 //shnarf
5445 //47=f1
5446 //59=esc
5447 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5448 // *((int32_t*)d->dp3) = k;
5449 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5450
5451
5452 d->flags&=~D_SELECTED;
5453 }
5454
5455 //Clears key to 0.
5456 //Used by all keyboard key settings dialogues.
5457 void kb_clearkey(DIALOG *d)
5458 {
5459 d->flags|=D_SELECTED;
5460
5461 scare_mouse();
5462 jwin_button_proc(MSG_DRAW,d,0);
5463 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5464 // text_mode(vc(11));
5465 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5466 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5467 unscare_mouse();
5468
5469 update_hw_screen(true);
5470
5471 clear_keybuf();
5472 int32_t k = next_press_key();
5473 clear_keybuf();
5474
5475 //shnarf
5476 //47=f1
5477 //59=esc
5478 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5479 // *((int32_t*)d->dp3) = k;
5480 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5481
5482
5483 d->flags&=~D_SELECTED;
5484 }
5485
5486
5487 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5488 {
5489 switch(msg)
5490 {
5491 case MSG_KEY:
5492 case MSG_CLICK:
5493
5494 kb_clearjoystick(d);
5495
5496 while(gui_mouse_b())
5497 {
5498 clear_keybuf();
5499 rest(1);
5500 }
5501
5502 return D_REDRAW;
5503 }
5504
5505 return jwin_button_proc(msg,d,c);
5506 }
5507
5508 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5509 {
5510 switch(msg)
5511 {
5512 case MSG_KEY:
5513 case MSG_CLICK:
5514
5515 kb_getkey(d);
5516
5517 while(gui_mouse_b()) {
5518 clear_keybuf();
5519 rest(1);
5520 }
5521
5522 return D_REDRAW;
5523 }
5524
5525 return jwin_button_proc(msg,d,c);
5526 }
5527
5528 //Only used in keyboard settings dialogues to clear keys.
5529 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5530 {
5531 switch(msg)
5532 {
5533 case MSG_KEY:
5534 case MSG_CLICK:
5535
5536 kb_clearkey(d);
5537
5538 while(gui_mouse_b()) {
5539 clear_keybuf();
5540 rest(1);
5541 }
5542
5543 return D_REDRAW;
5544 }
5545
5546 return jwin_button_proc(msg,d,c);
5547 }
5548
5549 void j_getbtn(DIALOG *d)
5550 {
5551 d->flags|=D_SELECTED;
5552 scare_mouse();
5553 jwin_button_proc(MSG_DRAW,d,0);
5554 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5555 // text_mode(vc(11));
5556 int32_t y = gui_bmp->h/2 - 12;
5557 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5558 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5559 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5560 unscare_mouse();
5561
5562 update_hw_screen(true);
5563
5564 int32_t b = next_press_btn();
5565
5566 if(b>=0)
5567 *((int32_t*)d->dp3) = b;
5568
5569 d->flags&=~D_SELECTED;
5570
5571 if (player)
5572 player->joy_on = TRUE;
5573 }
5574
5575 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5576 {
5577 switch(msg)
5578 {
5579 case MSG_KEY:
5580 case MSG_CLICK:
5581
5582 j_getbtn(d);
5583
5584 while(gui_mouse_b()) {
5585 rest(1);
5586 clear_keybuf();
5587 }
5588
5589 return D_REDRAW;
5590 }
5591
5592 return jwin_button_proc(msg,d,c);
5593 }
5594
5595 //shnarf
5596 const char *key_str[] =
5597 {
5598 "(none) ", "a ", "b ", "c ",
5599 "d ", "e ", "f ", "g ",
5600 "h ", "i ", "j ", "k ",
5601 "l ", "m ", "n ", "o ",
5602 "p ", "q ", "r ", "s ",
5603 "t ", "u ", "v ", "w ",
5604 "x ", "y ", "z ", "0 ",
5605 "1 ", "2 ", "3 ", "4 ",
5606 "5 ", "6 ", "7 ", "8 ",
5607 "9 ", "num 0 ", "num 1 ", "num 2 ",
5608 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5609 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5610 "f2 ", "f3 ", "f4 ", "f5 ",
5611 "f6 ", "f7 ", "f8 ", "f9 ",
5612 "f10 ", "f11 ", "f12 ", "esc ",
5613 "~ ", "- ", "= ", "backspace ",
5614 "tab ", "{ ", "} ", "enter ",
5615 ": ", "quote ", "\\ ", "\\ (2) ",
5616 ", ", ". ", "/ ", "space ",
5617 "insert ", "delete ", "home ", "end ",
5618 "page up ", "page down ", "left ", "right ",
5619 "up ", "down ", "num / ", "num * ",
5620 "num - ", "num + ", "num delete ", "num enter ",
5621 "print screen ", "pause ", "abnt c1 ", "yen ",
5622 "kana ", "convert ", "no convert ", "at ",
5623 "circumflex ", ": (2) ", "kanji ", "num = ",
5624 "back quote ", "; ", "command ", "unknown (0) ",
5625 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5626 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5627 "right shift ", "left control ", "right control", "alt ",
5628 "alt gr ", "left win ", "right win ", "menu ",
5629 "scroll lock ", "number lock ", "caps lock ", "MAX"
5630 };
5631
5632
5633 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5634 //extern int32_t zcmusic_bufsz;
5635
5636 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5637 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5638
5639 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5640 {
5641 //these are here to bypass compiler warnings about unused arguments
5642 c=c;
5643
5644 if(msg==MSG_DRAW)
5645 {
5646 switch(d->w)
5647 {
5648 case 0:
5649 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5650 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5651 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5652 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5653 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5654 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5655 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5656 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5657 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5658 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5659 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5660 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5661 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5662 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5663 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5664 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5665 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5666 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5667 break;
5668
5669 case 1:
5670 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5671 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5672 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5673 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5674 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5675 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5676 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5677 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5678 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5679 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5680 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5681 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5682 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5683 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5684 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5685 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5686 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5687 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5688 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5689 break;
5690
5691 case 2:
5692 sprintf(str_a," %3d",midi_volume);
5693 sprintf(str_b," %3d",digi_volume);
5694 sprintf(str_l," %3d",emusic_volume);
5695 sprintf(str_m," %3dKB",zcmusic_bufsz);
5696 sprintf(str_r," %3d",sfx_volume);
5697 strcpy(str_s,pan_str[pan_style]);
5698 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5699 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5700 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5701 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5702 break;
5703 }
5704 }
5705
5706 return D_O_K;
5707 }
5708
5709 int32_t set_vol(void *dp3, int32_t d2)
5710 {
5711 switch(((int32_t*)dp3)[0])
5712 {
5713 case 0:
5714 midi_volume = zc_min(d2<<3,255);
5715 break;
5716
5717 case 1:
5718 digi_volume = zc_min(d2<<3,255);
5719 break;
5720
5721 case 2:
5722 emusic_volume = zc_min(d2<<3,255);
5723 break;
5724
5725 case 3:
5726 sfx_volume = zc_min(d2<<3,255);
5727 break;
5728 }
5729
5730 scare_mouse();
5731 // text_mode(vc(11));
5732 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5733 unscare_mouse();
5734 return D_O_K;
5735 }
5736
5737 int32_t set_pan(void *dp3, int32_t d2)
5738 {
5739 pan_style = vbound(d2,0,3);
5740 scare_mouse();
5741 // text_mode(vc(11));
5742 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5743 unscare_mouse();
5744 return D_O_K;
5745 }
5746
5747 int32_t set_buf(void *dp3, int32_t d2)
5748 {
5749 scare_mouse();
5750 // text_mode(vc(11));
5751 zcmusic_bufsz = d2 + 1;
5752 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5753 unscare_mouse();
5754 return D_O_K;
5755 }
5756
5757 static int32_t gamepad_btn_list[] =
5758 {
5759 6,
5760 7,8,9,10,11,12,13,14,15,16,17,
5761 18,19,20,21,22,23,24,25,26,27,28,
5762 29,30,31,32,33,34,35,36,37,38,39,
5763 -1
5764 };
5765
5766 static int32_t gamepad_dirs_list[] =
5767 {
5768 40,41,42,43,
5769 44,45,46,47,
5770 48,49,50,51,
5771 52,53,54,55,
5772 56,
5773 -1
5774 };
5775
5776 static TABPANEL gamepad_tabs[] =
5777 {
5778 // (text)
5779 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5780 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5781 { NULL, 0, NULL, 0, NULL }
5782 };
5783
5784 static DIALOG gamepad_dlg[] =
5785 {
5786 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5787 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5788 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5789 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5790 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5791 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5792 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5793 // 6
5794 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5795 // 7
5796 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5797 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5798 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5799 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5800 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5801 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5802 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5803 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5804 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5805 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5806 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5807 // 18
5808 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5809 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5810 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5811 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5812 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5813 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5814 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5815 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5816 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5817 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5818 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5819 // 29
5820 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5821 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5822 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5823 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5824 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5825 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5826 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5827 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5828 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5829 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5830 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5831 // 40
5832 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5833 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5834 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5835 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5836 // 44
5837 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5838 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5839 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5840 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5841 // 48
5842 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5843 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5844 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5845 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5846 // 52
5847 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5848 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5849 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5850 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5851 // 56
5852 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5853 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5854 };
5855
5856 static int32_t keyboard_keys_list[] =
5857 {
5858 6,7,8,9,10,
5859 11,12,13,14,15,16,17,18,19,20,
5860 21,22,23,24,25,26,27,28,29,30,
5861 31,32,33,34,35,36,37,38,39,40,
5862 -1
5863 };
5864
5865 static int32_t keyboard_dirs_list[] =
5866 {
5867 41,42,43,44,
5868 45,46,47,48,
5869 49,50,51,52,
5870 53,54,55,56,
5871 -1
5872 };
5873
5874 static int32_t keyboard_mods_list[] =
5875 {
5876 57,58,59,60,
5877 61,62,63,64,
5878 65,66,67,68,
5879 69,70,71,72,
5880 -1
5881 };
5882
5883 static TABPANEL keyboard_control_tabs[] =
5884 {
5885 // (text)
5886 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5887 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5888 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5889 { NULL, 0, NULL, 0, NULL }
5890 };
5891
5892 static DIALOG keyboard_control_dlg[] =
5893 {
5894 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5895 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5896 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5897 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5898 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5899 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5900 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5901 // Keys
5902 // 6
5903 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5904 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5905 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5906 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5907 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5908 // 11
5909 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5910 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5911 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5912 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5913 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5914 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5915 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5916 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5917 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5918 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5919 // 21
5920 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5921 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5922 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5923 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5924 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5925 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5926 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5927 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5928 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5929 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5930 // 31
5931 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5932 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5933 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5934 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5935 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5936 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5937 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5938 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5939 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5940 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5941 // Dirs
5942 // 41
5943 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5944 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5945 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5946 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5947 // 45
5948 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5949 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5950 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5951 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5952 // 49
5953 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5954 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5955 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5956 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5957 // 53
5958 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5959 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5960 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5961 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5962 // Mods
5963 // 57
5964 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5965 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5966 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5967 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5968 // 61
5969 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5970 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5971 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5972 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5973 // 65
5974 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5975 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5976 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5977 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5978 // 69
5979 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5980 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5981 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5982 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5983 // 73
5984 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5985 };
5986
5987 /*
5988 int32_t midi_dp[3] = {0,147,104};
5989 int32_t digi_dp[3] = {1,147,120};
5990 int32_t pan_dp[3] = {0,147,136};
5991 int32_t buf_dp[3] = {0,147,152};
5992 */
5993 int32_t midi_dp[3] = {0,0,0};
5994 int32_t digi_dp[3] = {1,0,0};
5995 int32_t emus_dp[3] = {2,0,0};
5996 int32_t buf_dp[3] = {0,0,0};
5997 int32_t sfx_dp[3] = {3,0,0};
5998 int32_t pan_dp[3] = {0,0,0};
5999
6000 static DIALOG sound_dlg[] =
6001 {
6002 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
6003 11 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
6004 11 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6005 11 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6006 11 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6007 11 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6008 11 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6009 11 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
6010 11 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
6011 11 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
6012 11 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
6013 // 10
6014 11 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
6015 11 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
6016 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6017 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6018 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6019 11 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
6020 11 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
6021 11 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
6022 11 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
6023 11 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
6024 //20
6025 11 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
6026 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6027 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6028 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6029 11 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
6030 11 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
6031 11 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
6032 11 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
6033 11 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6034 11 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6035 //30
6036 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6037 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6038 11 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6039 11 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6040 };
6041
6042 char zc_builddate[80];
6043 char zc_aboutstr[80];
6044
6045 static DIALOG about_dlg[] =
6046 {
6047 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6048 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6049 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6050 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6051 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6052 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6053 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6054 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6055 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6056 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6057 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6058 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6059 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6060 };
6061
6062
6063 static DIALOG quest_dlg[] =
6064 {
6065 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6066 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6067 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6068 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6069 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6070 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6071 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, QHeader.version, NULL, NULL },
6072 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6073 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6074 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6075 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6076 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6077 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6078 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6079 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6080 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6081 };
6082
6083 static DIALOG triforce_dlg[] =
6084 {
6085 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6086 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6087 // 1
6088 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6089 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6090 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6091 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6092 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6093 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6094 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6095 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6096 // 9
6097 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6098 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6099 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6100 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6101 };
6102
6103 /*static DIALOG equip_dlg[] =
6104 {
6105 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6106 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6107 // 1
6108 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6109 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6110 // 3
6111 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6112 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6113 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6114 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6115 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6116 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6117 // 9
6118 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6119 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6120 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6121 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6122 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6123 // 14
6124 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6125 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6126 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6127 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6128 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6129 // 19
6130 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6131 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6132 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6133 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6134 // 23
6135 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6136 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6137 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6138 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6139 // 27
6140 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6141 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6142 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6143 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6144 // 31
6145 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6146 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6147 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6148 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6149 // 35
6150 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6151 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6152 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6153 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6154 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6155 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6156 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6157 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6158 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6159 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6160 };
6161
6162 static DIALOG items_dlg[] =
6163 {
6164 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6165 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6166 //1
6167 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6168 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6169 // 3
6170 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6171 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6172 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6173 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6174 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6175 // 8
6176 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6177 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6178 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6179 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6180 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6181 // 13
6182 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6183 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6184 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6185 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6186 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6187 // 18
6188 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6189 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6190 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6191 // 21
6192 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6193 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6194 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6195 // 24
6196 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6197 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6198 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6199 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6200 // 28
6201 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6202 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6203 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6204 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6205 // 32
6206 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6207 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6208 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6209 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6210 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6211 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6212 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6213 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6214 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6215 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6216 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6217 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6218 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6219 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6220 //45
6221 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6222 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6223 };*/
6224
6225
6226
6227 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6228 {
6229 go();
6230 int32_t ret=0;
6231 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6232 comeback();
6233 return ret != 0;
6234 }
6235
6236
6237 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6238 {
6239 if(def!=modulepath)
6240 strcpy(modulepath,def);
6241
6242 if(!usefilename)
6243 {
6244 int32_t i=(int32_t)strlen(modulepath);
6245
6246 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6247 modulepath[i--]=0;
6248 }
6249
6250 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6251 int32_t ret=0;
6252 int32_t sel=0;
6253
6254 if(list==NULL)
6255 {
6256 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6257 }
6258 else
6259 {
6260 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6261 }
6262
6263 return ret!=0;
6264 }
6265
6266 //The Dialogue that loads a ZMOD Module File
6267 int32_t zc_load_zmod_module_file()
6268 {
6269 if ( Playing )
6270 {
6271 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6272 return -1;
6273 }
6274 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6275 return D_CLOSE;
6276
6277 FILE *tempmodule = fopen(modulepath,"r");
6278
6279 if(tempmodule == NULL)
6280 {
6281 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6282 return -1;
6283 }
6284
6285
6286 //Set the module path:
6287 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6288 strcpy(moduledata.module_name, modulepath);
6289 al_trace("New Module Path is: %s \n", moduledata.module_name);
6290 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6291 zcm.init(true); //Load the module values.
6292 moduledata.refresh_title_screen = 1;
6293 // refresh_select_screen = 1;
6294 build_biic_list();
6295 return D_O_K;
6296 }
6297
6298 static DIALOG module_info_dlg[] =
6299 {
6300 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6301
6302
6303 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6304 //1
6305 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6306 //2
6307 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6308 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6309 //4
6310 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6311 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6312 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6313 //7
6314
6315 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6316 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6317 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6318 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6319 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6320 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6321 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6322 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6323 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6324
6325 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6326 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6327 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6328 };
6329
6330 void about_zcplayer_module(const char *prompt,int32_t initialval)
6331 {
6332
6333 module_info_dlg[0].dp2 = lfont;
6334 if ( moduledata.moduletitle[0] != 0 )
6335 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6336
6337 if ( moduledata.moduleauthor[0] != 0 )
6338 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6339
6340 if ( moduledata.moduleinfo0[0] != 0 )
6341 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6342 if ( moduledata.moduleinfo1[0] != 0 )
6343 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6344 if ( moduledata.moduleinfo2[0] != 0 )
6345 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6346 if ( moduledata.moduleinfo3[0] != 0 )
6347 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6348 if ( moduledata.moduleinfo4[0] != 0 )
6349 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6350
6351 char module_date[255];
6352 memset(module_date, 0, sizeof(module_date));
6353 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6354 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6355
6356
6357
6358 char module_vers[255];
6359 memset(module_vers, 0, sizeof(module_vers));
6360 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6361
6362
6363 //sprintf(tilecount,"%d",1);
6364
6365 char module_build[255];
6366 memset(module_build, 0, sizeof(module_build));
6367 if ( moduledata.modbeta )
6368 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6369 else
6370 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6371
6372 module_info_dlg[12].dp = (char*)module_date;
6373 module_info_dlg[13].dp = (char*)module_vers;
6374 module_info_dlg[14].dp = (char*)module_build;
6375
6376 if(is_large)
6377 large_dialog(module_info_dlg);
6378
6379 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6380 jwin_center_dialog(module_info_dlg);
6381
6382
6383 }
6384
6385 int32_t onAbout_ZCP_Module()
6386 {
6387 about_zcplayer_module("About Module (.zmod)", 0);
6388 return D_O_K;
6389 }
6390
6391 //New Modules Menu for 2.55+
6392 static MENU zcmodule_menu[] =
6393 {
6394 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6395 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6396
6397 { NULL, NULL, NULL, 0, NULL }
6398 };
6399
6400 int32_t onToggleRecordingNewSaves()
6401 {
6402 if (zc_get_config("zeldadx", "replay_new_saves", false))
6403 {
6404 zc_set_config("zeldadx", "replay_new_saves", false);
6405 }
6406 else
6407 {
6408 zc_set_config("zeldadx", "replay_new_saves", true);
6409 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6410 NULL,NULL,"OK",NULL,13,27,lfont);
6411 }
6412 return D_O_K;
6413 }
6414
6415 int32_t onStopReplayOrRecord()
6416 {
6417 if (replay_is_replaying())
6418 {
6419 replay_quit();
6420 }
6421 else if (replay_get_mode() == ReplayMode::Record)
6422 {
6423 if (!replay_get_meta_bool("test_mode"))
6424 {
6425 jwin_alert("Recording", "You cannot stop recording a save file.",
6426 NULL,NULL,"OK",NULL,13,27,lfont);
6427 return D_CLOSE;
6428 }
6429
6430 if (jwin_alert("Stop Recording",
6431 "Save replay to disk and stop recording?",
6432 "This will stop the recording.",
6433 NULL,
6434 "Yes","No",13,27,lfont) != 1)
6435 return D_CLOSE;
6436
6437 replay_save();
6438 replay_stop();
6439 }
6440 return D_O_K;
6441 }
6442
6443 static int32_t handle_on_load_replay(ReplayMode mode)
6444 {
6445 if (Playing)
6446 {
6447 if (jwin_alert("Replay - Warning!",
6448 "Loading a replay will exit the current game.",
6449 "All unsaved progress will be lost.",
6450 "Do you wish to continue?",
6451 "Yes","No",13,27,lfont) != 1)
6452 return D_CLOSE;
6453 }
6454
6455 std::string mode_string = replay_mode_to_string(mode);
6456 mode_string[0] = std::toupper(mode_string[0]);
6457
6458 std::string line_1 = "Select a replay file to play back.";
6459 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6460 std::string line_3 = "You can stop the replay and take over manually any time.";
6461 if (mode == ReplayMode::Update)
6462 {
6463 line_1 = "Select a replay file to update.";
6464 line_2 = "WARNING: be sure to back up the zplay file";
6465 line_3 = "and verify that the updated replay works as expected!";
6466 }
6467
6468 if (jwin_alert(mode_string.c_str(),
6469 line_1.c_str(),
6470 line_2.c_str(),
6471 line_3.c_str(),
6472 "OK","Nevermind",13,27,lfont) == 1)
6473 {
6474 char replay_path[2048];
6475 strcpy(replay_path, "replays/");
6476 if (jwin_file_select_ex(
6477 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6478 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6479 return D_CLOSE;
6480
6481 replay_quit();
6482 load_replay_file_deferred(mode, replay_path);
6483 Quit = qRESET;
6484 return D_CLOSE;
6485 }
6486 return D_O_K;
6487 }
6488
6489 int32_t onLoadReplay()
6490 {
6491 return handle_on_load_replay(ReplayMode::Replay);
6492 }
6493
6494 int32_t onLoadReplayAssert()
6495 {
6496 return handle_on_load_replay(ReplayMode::Assert);
6497 }
6498
6499 int32_t onLoadReplayUpdate()
6500 {
6501 return handle_on_load_replay(ReplayMode::Update);
6502 }
6503
6504 int32_t onSaveReplay()
6505 {
6506 if (replay_get_mode() == ReplayMode::Record)
6507 {
6508 if (!replay_get_meta_bool("test_mode"))
6509 {
6510 if (jwin_alert("Save Replay",
6511 "This will save a copy of the replay up to this point.",
6512 "The official replay file will be untouched.",
6513 "Do you wish to continue?",
6514 "Yes","No",13,27,lfont) != 1)
6515 return D_CLOSE;
6516
6517 char replay_path[2048];
6518 strcpy(replay_path, replay_get_filename().c_str());
6519 if (jwin_file_select_ex(
6520 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6521 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6522 return D_CLOSE;
6523
6524 if (fileexists(replay_path))
6525 {
6526 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6527 NULL,NULL,"OK",NULL,13,27,lfont);
6528 return D_CLOSE;
6529 }
6530
6531 replay_save(replay_path);
6532 }
6533 else
6534 {
6535 replay_save();
6536 }
6537 }
6538 return D_O_K;
6539 }
6540
6541 static MENU replay_menu[] =
6542 {
6543 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6544 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6545 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6546 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6547 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6548 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6549
6550 { NULL, NULL, NULL, 0, NULL }
6551 };
6552
6553 static DIALOG credits_dlg[] =
6554 {
6555 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6556 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6557 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6558 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6559 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6560 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6561 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6562 };
6563
6564 11 static ListData dmap_list(dmaplist, &font);
6565
6566 static DIALOG goto_dlg[] =
6567 {
6568 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6569 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6570 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6571 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6572 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6573 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6574 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6575 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6576 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6577 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6578 };
6579
6580 int32_t onGoTo()
6581 {
6582 bool music = false;
6583 music = music;
6584 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6585
6586 goto_dlg[0].dp2=lfont;
6587 goto_dlg[4].d2=cheat_goto_dmap;
6588 goto_dlg[6].dp=cheat_goto_screen_str;
6589
6590 clear_keybuf();
6591
6592 if(is_large)
6593 large_dialog(goto_dlg);
6594
6595 if(zc_popup_dialog(goto_dlg,4)==1)
6596 {
6597 // dmap, screen
6598 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6599 };
6600
6601 return D_O_K;
6602 }
6603
6604 int32_t onGoToComplete()
6605 {
6606 if(!Playing)
6607 {
6608 return D_O_K;
6609 }
6610
6611 system_pal();
6612 music_pause();
6613 pause_all_sfx();
6614 show_mouse(screen);
6615 onGoTo();
6616 eat_buttons();
6617
6618 zc_readrawkey(KEY_ESC);
6619
6620 show_mouse(NULL);
6621 game_pal();
6622 music_resume();
6623 resume_all_sfx();
6624 return D_O_K;
6625 }
6626
6627 int32_t onCredits()
6628 {
6629 go();
6630
6631 BITMAP *win = create_bitmap_ex(8,222,110);
6632
6633 if(!win)
6634 return D_O_K;
6635
6636 int32_t c=0;
6637 int32_t l=0;
6638 int32_t ol=-1;
6639 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6640 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6641 PALETTE tmppal;
6642
6643 rti_gui.transparency_index = 1;
6644
6645 clear_to_color(win, rti_gui.transparency_index);
6646 draw_rle_sprite(win,rle,0,0);
6647 credits_dlg[0].dp2=lfont;
6648 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6649 credits_dlg[2].dp = win;
6650
6651 set_palette_range(black_palette,0,127,false);
6652
6653 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6654
6655 BITMAP* old_screen = screen;
6656 BITMAP* gui_bmp = zc_get_gui_bmp();
6657 ASSERT(gui_bmp);
6658 clear_to_color(gui_bmp, rti_gui.transparency_index);
6659 screen = gui_bmp;
6660
6661 while(update_dialog(p))
6662 {
6663 throttleFPS();
6664 ++c;
6665 l = zc_max((c>>1)-30,0);
6666
6667 if(l > rle->h)
6668 l = c = 0;
6669
6670 if(l > rle->h - 112)
6671 l = rle->h - 112;
6672
6673 clear_bitmap(win);
6674 draw_rle_sprite(win,rle,0,0-l);
6675
6676 if(c<=64)
6677 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6678
6679 set_palette_range(tmppal,0,127,false);
6680
6681 if(l!=ol)
6682 {
6683 scare_mouse();
6684 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6685 unscare_mouse();
6686 SCRFIX();
6687 ol=l;
6688 }
6689
6690 update_hw_screen();
6691 }
6692
6693 screen = old_screen;
6694 system_pal();
6695
6696 shutdown_dialog(p);
6697 destroy_bitmap(win);
6698 //comeback();
6699
6700 rti_gui.transparency_index = 0;
6701
6702 return D_O_K;
6703 }
6704
6705 const char *midilist(int32_t index, int32_t *list_size)
6706 {
6707 if(index<0)
6708 {
6709 *list_size=0;
6710
6711 for(int32_t i=0; i<MAXMIDIS; i++)
6712 if(tunes[i].data)
6713 ++(*list_size);
6714
6715 return NULL;
6716 }
6717
6718 int32_t i=0,m=0;
6719
6720 while(m<=index && i<=MAXMIDIS)
6721 {
6722 if(tunes[i].data)
6723 ++m;
6724
6725 ++i;
6726 }
6727
6728 --i;
6729
6730 if(i==MAXMIDIS && m<index)
6731 return "(null)";
6732
6733 return tunes[i].title;
6734 }
6735
6736 /* ------- MIDI info stuff -------- */
6737
6738 char *text;
6739 midi_info *zmi;
6740 bool dialog_running;
6741 bool listening;
6742
6743 void get_info(int32_t index);
6744
6745 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6746 {
6747 int32_t d2 = d->d2;
6748 int32_t ret = jwin_droplist_proc(msg,d,c);
6749
6750 if(d2!=d->d2)
6751 {
6752 get_info(d->d2);
6753 }
6754
6755 return ret;
6756 }
6757
6758 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6759 {
6760 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6761
6762 int32_t ret = jwin_button_proc(msg,d,c);
6763
6764 if(ret == D_CLOSE)
6765 {
6766 // get current midi index
6767 int32_t index = (d+(d->d1))->d2;
6768 int32_t i=0, m=0;
6769
6770 while(m<=index && i<=MAXMIDIS)
6771 {
6772 if(tunes[i].data)
6773 ++m;
6774
6775 ++i;
6776 }
6777
6778 --i;
6779 jukebox(i);
6780 listening = true;
6781 ret = D_O_K;
6782 }
6783
6784 return ret;
6785 }
6786
6787 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6788 {
6789 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6790
6791 int32_t ret = jwin_button_proc(msg,d,c);
6792
6793 if(ret == D_CLOSE)
6794 {
6795 // get current midi index
6796 int32_t index = (d+(d->d1))->d2;
6797 int32_t i=0, m=0;
6798
6799 while(m<=index && i<=MAXMIDIS)
6800 {
6801 if(tunes[i].data)
6802 ++m;
6803
6804 ++i;
6805 }
6806
6807 --i;
6808
6809 // get file name
6810
6811 int32_t sel=0;
6812 //struct ffblk f;
6813 char title[40] = "Save MIDI: ";
6814 char fname[2048];
6815 memset(fname,0,2048);
6816 static EXT_LIST list[] =
6817 {
6818 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6819 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6820 { NULL, NULL }
6821 };
6822
6823 strcpy(title+11, tunes[i].title);
6824 title[39] = '\0';
6825
6826 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6827 goto done;
6828
6829 if(exists(fname))
6830 {
6831 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6832 goto done;
6833 }
6834
6835 // save midi i
6836
6837 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6838 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6839
6840 done:
6841 chop_path(fname);
6842 ret = D_REDRAW;
6843 }
6844
6845 return ret;
6846 }
6847
6848 11 static ListData midi_list(midilist, &font);
6849
6850 static DIALOG midi_dlg[] =
6851 {
6852 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6853 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6854 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6855 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6856 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6857 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6858 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6859 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6860 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6861 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6862 };
6863
6864 void get_info(int32_t index)
6865 {
6866 int32_t i=0, m=0;
6867
6868 while(m<=index && i<=MAXMIDIS)
6869 {
6870 if(tunes[i].data)
6871 ++m;
6872
6873 ++i;
6874 }
6875
6876 --i;
6877
6878 if(i==MAXMIDIS && m<index)
6879 strcpy(text,"(null)");
6880 else
6881 {
6882 get_midi_info((MIDI*)tunes[i].data,zmi);
6883 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6884 }
6885
6886 midi_dlg[0].dp2=lfont;
6887 midi_dlg[3].dp = text;
6888 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6889 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6890
6891 if(dialog_running)
6892 {
6893 scare_mouse();
6894 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6895 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6896 unscare_mouse();
6897 }
6898 }
6899
6900 int32_t onMIDICredits()
6901 {
6902 text = (char*)malloc(4096);
6903 zmi = (midi_info*)malloc(sizeof(midi_info));
6904
6905 if(!text || !zmi)
6906 {
6907 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6908 return D_O_K;
6909 }
6910
6911 bool do_pause_midi = midi_pos >= 0 && currmidi;
6912 auto restore_midi = currmidi;
6913 if(do_pause_midi)
6914 {
6915 paused_midi_pos = midi_pos;
6916 stop_midi();
6917 midi_paused=true;
6918 midi_suspended = midissuspHALTED;
6919 }
6920
6921 midi_dlg[0].dp2=lfont;
6922 midi_dlg[2].d1 = 0;
6923 midi_dlg[2].d2 = 0;
6924 midi_dlg[4].flags = D_EXIT;
6925 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6926
6927 listening = false;
6928 dialog_running=false;
6929 get_info(0);
6930
6931 dialog_running=true;
6932
6933 if(is_large)
6934 large_dialog(midi_dlg);
6935
6936 zc_popup_dialog(midi_dlg,0);
6937 dialog_running=false;
6938
6939 if(listening)
6940 music_stop();
6941
6942 if(do_pause_midi)
6943 {
6944 midi_suspended = midissuspRESUME;
6945 currmidi = restore_midi;
6946 midi_pos = paused_midi_pos;
6947 }
6948
6949 if(text) free(text);
6950 if(zmi) free(zmi);
6951 return D_O_K;
6952 }
6953
6954 int32_t onAbout()
6955 {
6956 char buf1[80]={0};
6957 std::ostringstream oss;
6958 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6959 oss << buf1 << '\n';
6960 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6961 oss << buf1 << '\n';
6962 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6963 oss << buf1 << '\n';
6964 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6965 oss << buf1 << '\n';
6966
6967 InfoDialog("About ZC", oss.str()).show();
6968 return D_O_K;
6969 }
6970
6971 int32_t onQuest()
6972 {
6973 char fname[100];
6974 strcpy(fname, get_filename(qstpath));
6975 quest_dlg[0].dp2=lfont;
6976 quest_dlg[1].dp = fname;
6977
6978 if(QHeader.quest_number==0)
6979 sprintf(str_a,"Custom");
6980 else
6981 sprintf(str_a,"%d",QHeader.quest_number);
6982
6983 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6984
6985 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6986 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6987
6988 if(is_large)
6989 large_dialog(quest_dlg);
6990
6991 zc_popup_dialog(quest_dlg, 0);
6992 return D_O_K;
6993 }
6994
6995 void call_vidmode_dlg();
6996 int32_t onVidMode()
6997 {
6998 call_vidmode_dlg();
6999 return D_O_K;
7000 }
7001
7002 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
7003 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
7004 //Added an extra statement, so that if the key is cleared to 0, the cleared
7005 //keybinding status need not be unique. -Z ( 1st April, 2019 )
7006
7007 void load_ukeys(int32_t* arr)
7008 {
7009 arr[ukey_a] = Akey;
7010 arr[ukey_b] = Bkey;
7011 arr[ukey_s] = Skey;
7012 arr[ukey_l] = Lkey;
7013 arr[ukey_r] = Rkey;
7014 arr[ukey_p] = Pkey;
7015 arr[ukey_ex1] = Exkey1;
7016 arr[ukey_ex2] = Exkey2;
7017 arr[ukey_ex3] = Exkey3;
7018 arr[ukey_ex4] = Exkey4;
7019 arr[ukey_du] = DUkey;
7020 arr[ukey_dd] = DDkey;
7021 arr[ukey_dl] = DLkey;
7022 arr[ukey_dr] = DRkey;
7023 arr[ukey_mod1a] = cheat_modifier_keys[0];
7024 arr[ukey_mod1b] = cheat_modifier_keys[1];
7025 arr[ukey_mod2a] = cheat_modifier_keys[2];
7026 arr[ukey_mod2b] = cheat_modifier_keys[3];
7027 };
7028
7029 static const char* ukey_names[] = {
7030 "A", "B", "Start", "L", "R", "Map",
7031 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7032 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7033 "Cheat Mod R1", "Cheat Mod R2",
7034 };
7035 std::string get_ukey_name(int32_t k)
7036 {
7037 if (k < num_ukey) return ukey_names[k];
7038 return "";
7039 }
7040
7041 int32_t onKeyboard()
7042 {
7043 int32_t a = Akey;
7044 int32_t b = Bkey;
7045 int32_t s = Skey;
7046 int32_t l = Lkey;
7047 int32_t r = Rkey;
7048 int32_t p = Pkey;
7049 int32_t ex1 = Exkey1;
7050 int32_t ex2 = Exkey2;
7051 int32_t ex3 = Exkey3;
7052 int32_t ex4 = Exkey4;
7053 int32_t du = DUkey;
7054 int32_t dd = DDkey;
7055 int32_t dl = DLkey;
7056 int32_t dr = DRkey;
7057 int32_t mod1a = cheat_modifier_keys[0];
7058 int32_t mod1b = cheat_modifier_keys[1];
7059 int32_t mod2a = cheat_modifier_keys[2];
7060 int32_t mod2b = cheat_modifier_keys[3];
7061 bool done=false;
7062 int32_t ret;
7063
7064 keyboard_control_dlg[0].dp2=lfont;
7065
7066 if(is_large)
7067 large_dialog(keyboard_control_dlg);
7068
7069 while(!done)
7070 {
7071 ret = zc_popup_dialog(keyboard_control_dlg,3);
7072
7073 if(ret==3) // OK
7074 {
7075 int32_t ukeys[num_ukey];
7076 load_ukeys(ukeys);
7077 std::vector<std::string> uniqueError;
7078 for(int32_t q = 0; q < num_ukey; ++q)
7079 {
7080 for(int32_t p = q+1; p < num_ukey; ++p)
7081 {
7082 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7083 {
7084 char buf[64];
7085 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7086 std::string str(buf);
7087 uniqueError.push_back(str);
7088 }
7089 }
7090 }
7091 if(uniqueError.size() == 0)
7092 {
7093 done = true;
7094 save_control_configs(true);
7095 }
7096 else
7097 {
7098 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7099 box_out("Cannot have duplicate keybinds!"); box_eol();
7100 for(std::vector<std::string>::iterator it = uniqueError.begin();
7101 it != uniqueError.end(); ++it)
7102 {
7103 box_out((*it).c_str()); box_eol();
7104 }
7105 box_end(true);
7106 }
7107 /* Old uniqueness check
7108 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7109 bool unique = true;
7110 addToHash(A,unique,keyhash);
7111 addToHash(B,unique,keyhash);
7112 addToHash(S,unique,keyhash);
7113 addToHash(L,unique,keyhash);
7114 addToHash(R,unique,keyhash);
7115 addToHash(P,unique,keyhash);
7116 addToHash(DU,unique,keyhash);
7117 addToHash(DD,unique,keyhash);
7118 addToHash(DL,unique,keyhash);
7119 addToHash(DR,unique,keyhash);
7120
7121 if(keyhash->find(Exkey1) == keyhash->end())
7122 {
7123 (*keyhash)[Exkey1]=true;
7124 }
7125 else
7126 {
7127 if ( Exkey1 != 0 ) unique = false;
7128 }
7129
7130 if(keyhash->find(Exkey2) == keyhash->end())
7131 {
7132 (*keyhash)[Exkey2]=true;
7133 }
7134 else
7135 {
7136 if ( Exkey2 != 0 ) unique = false;
7137 }
7138
7139 if(keyhash->find(Exkey3) == keyhash->end())
7140 {
7141 (*keyhash)[Exkey3]=true;
7142 }
7143 else
7144 {
7145 if ( Exkey3 != 0 ) unique = false;
7146 }
7147
7148 if(keyhash->find(Exkey4) == keyhash->end())
7149 {
7150 (*keyhash)[Exkey4]=true;
7151 }
7152 else
7153 {
7154 if ( Exkey4 != 0 )unique = false;
7155 }
7156 //modifier keys
7157 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7158 {
7159 (*keyhash)[cheat_modifier_keys[0]]=true;
7160 }
7161 else
7162 {
7163 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7164 }
7165 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7166 {
7167 (*keyhash)[cheat_modifier_keys[1]]=true;
7168 }
7169 else
7170 {
7171 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7172 }
7173 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7174 {
7175 (*keyhash)[cheat_modifier_keys[2]]=true;
7176 }
7177 else
7178 {
7179 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7180 }
7181 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7182 {
7183 (*keyhash)[cheat_modifier_keys[3]]=true;
7184 }
7185 else
7186 {
7187 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7188 }
7189
7190 delete keyhash;
7191
7192 if(unique)
7193 done=true;
7194 else
7195 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7196 */
7197 }
7198 else // Cancel
7199 {
7200 Akey = a;
7201 Bkey = b;
7202 Skey = s;
7203 Lkey = l;
7204 Rkey = r;
7205 Pkey = p;
7206 Exkey1 = ex1;
7207 Exkey2 = ex2;
7208 Exkey3 = ex3;
7209 Exkey4 = ex4;
7210 DUkey = du;
7211 DDkey = dd;
7212 DLkey = dl;
7213 DRkey = dr;
7214 cheat_modifier_keys[0] = mod1a;
7215 cheat_modifier_keys[1] = mod1b;
7216 cheat_modifier_keys[2] = mod2a;
7217 cheat_modifier_keys[3] = mod2b;
7218
7219 done=true;
7220 }
7221
7222 rest(1);
7223 }
7224
7225 return D_O_K;
7226 }
7227
7228 int32_t onGamepad()
7229 {
7230 int32_t a = Abtn;
7231 int32_t b = Bbtn;
7232 int32_t s = Sbtn;
7233 int32_t l = Lbtn;
7234 int32_t r = Rbtn;
7235 int32_t m = Mbtn;
7236 int32_t p = Pbtn;
7237 int32_t ex1 = Exbtn1;
7238 int32_t ex2 = Exbtn2;
7239 int32_t ex3 = Exbtn3;
7240 int32_t ex4 = Exbtn4;
7241 int32_t up = DUbtn;
7242 int32_t down = DDbtn;
7243 int32_t left = DLbtn;
7244 int32_t right = DRbtn;
7245
7246 gamepad_dlg[0].dp2=lfont;
7247 if(analog_movement)
7248 gamepad_dlg[56].flags|=D_SELECTED;
7249 else
7250 gamepad_dlg[56].flags&=~D_SELECTED;
7251
7252 if(is_large)
7253 large_dialog(gamepad_dlg);
7254
7255 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7256
7257 if(ret == 4) //OK
7258 {
7259 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7260 save_control_configs(false);
7261 }
7262 else //Cancel
7263 {
7264 Abtn = a;
7265 Bbtn = b;
7266 Sbtn = s;
7267 Lbtn = l;
7268 Rbtn = r;
7269 Mbtn = m;
7270 Pbtn = p;
7271 Exbtn1 = ex1;
7272 Exbtn2 = ex2;
7273 Exbtn3 = ex3;
7274 Exbtn4 = ex4;
7275 DUbtn = up;
7276 DDbtn = down;
7277 DLbtn = left;
7278 DRbtn = right;
7279 }
7280
7281 return D_O_K;
7282 }
7283
7284 int32_t onSound()
7285 {
7286 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7287 {
7288 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7289 }
7290 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7291 {
7292 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7293 }
7294 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7295 {
7296 emusic_volume = (int32_t)FFCore.usr_music_volume;
7297 }
7298 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7299 {
7300 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7301 }
7302 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7303 {
7304 pan_style = (int32_t)FFCore.usr_panstyle;
7305 }
7306
7307 int32_t m = midi_volume;
7308 int32_t d = digi_volume;
7309 int32_t e = emusic_volume;
7310 int32_t b = zcmusic_bufsz;
7311 int32_t s = sfx_volume;
7312 int32_t p = pan_style;
7313 pan_style = vbound(pan_style,0,3);
7314
7315 sound_dlg[0].dp2=lfont;
7316
7317 if(is_large)
7318 large_dialog(sound_dlg);
7319
7320 midi_dp[1] = sound_dlg[6].x;
7321 midi_dp[2] = sound_dlg[6].y;
7322 digi_dp[1] = sound_dlg[7].x;
7323 digi_dp[2] = sound_dlg[7].y;
7324 emus_dp[1] = sound_dlg[8].x;
7325 emus_dp[2] = sound_dlg[8].y;
7326 buf_dp[1] = sound_dlg[9].x;
7327 buf_dp[2] = sound_dlg[9].y;
7328 sfx_dp[1] = sound_dlg[10].x;
7329 sfx_dp[2] = sound_dlg[10].y;
7330 pan_dp[1] = sound_dlg[11].x;
7331 pan_dp[2] = sound_dlg[11].y;
7332 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7333 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7334 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7335 sound_dlg[18].d2 = zcmusic_bufsz;
7336 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7337 sound_dlg[20].d2 = pan_style;
7338
7339 int32_t ret = zc_popup_dialog(sound_dlg,1);
7340
7341 if(ret==2)
7342 {
7343 master_volume(digi_volume,midi_volume);
7344
7345 for(int32_t i=0; i<WAV_COUNT; ++i)
7346 {
7347 //allegro assertion fails when passing in -1 as voice -DD
7348 if(sfx_voice[i] > 0)
7349 voice_set_volume(sfx_voice[i], sfx_volume);
7350 }
7351 zc_set_config(sfx_sect,"digi",digi_volume);
7352 zc_set_config(sfx_sect,"midi",midi_volume);
7353 zc_set_config(sfx_sect,"sfx",sfx_volume);
7354 zc_set_config(sfx_sect,"emusic",emusic_volume);
7355 zc_set_config(sfx_sect,"pan",pan_style);
7356 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7357 }
7358 else
7359 {
7360 midi_volume = m;
7361 digi_volume = d;
7362 emusic_volume = e;
7363 zcmusic_bufsz = b;
7364 sfx_volume = s;
7365 pan_style = p;
7366 }
7367
7368 return D_O_K;
7369 }
7370
7371 int32_t queding(char const* s1, char const* s2, char const* s3)
7372 {
7373 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7374 }
7375
7376 int32_t onQuit()
7377 {
7378 if(Playing)
7379 {
7380 int32_t ret=0;
7381
7382 if(get_bit(quest_rules, qr_NOCONTINUE))
7383 {
7384 if(standalone_mode)
7385 {
7386 ret=queding("End current game?",
7387 "The continue screen is disabled; the game",
7388 "will be reloaded from the last save.");
7389 }
7390 else
7391 {
7392 ret=queding("End current game?",
7393 "The continue screen is disabled. You will",
7394 "be returned to the file select screen.");
7395 }
7396 }
7397 else
7398 ret=queding("End current game?",NULL,NULL);
7399
7400 if(ret==1)
7401 {
7402 disableClickToFreeze=false;
7403 Quit=qQUIT;
7404
7405 // Trying to evade a door repair charge?
7406 if(repaircharge)
7407 {
7408 game->change_drupy(-repaircharge);
7409 repaircharge=0;
7410 }
7411
7412 return D_CLOSE;
7413 }
7414 }
7415
7416 return D_O_K;
7417 }
7418
7419 int32_t onTryQuitMenu()
7420 {
7421 return onTryQuit(true);
7422 }
7423
7424 int32_t onTryQuit(bool inMenu)
7425 {
7426 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7427 {
7428 if(get_bit(quest_rules,qr_OLD_F6))
7429 {
7430 if(inMenu) onQuit();
7431 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7432 }
7433 else
7434 {
7435 disableClickToFreeze=false;
7436 GameFlags |= GAMEFLAG_TRYQUIT;
7437 }
7438 return D_CLOSE;
7439 }
7440
7441 return D_O_K;
7442 }
7443
7444 int32_t onReset()
7445 {
7446 if(queding(" Reset system? ",NULL,NULL)==1)
7447 {
7448 disableClickToFreeze=false;
7449 Quit=qRESET;
7450 replay_quit();
7451 return D_CLOSE;
7452 }
7453
7454 return D_O_K;
7455 }
7456
7457 int32_t onExit()
7458 {
7459 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7460 {
7461 Quit=qEXIT;
7462 return D_CLOSE;
7463 }
7464
7465 return D_O_K;
7466 }
7467
7468 int32_t onTitle_NES()
7469 {
7470 title_version=0;
7471 zc_set_config(cfg_sect,"title",title_version);
7472 return D_O_K;
7473 }
7474 int32_t onTitle_DX()
7475 {
7476 title_version=1;
7477 zc_set_config(cfg_sect,"title",title_version);
7478 return D_O_K;
7479 }
7480 int32_t onTitle_25()
7481 {
7482 title_version=2;
7483 zc_set_config(cfg_sect,"title",title_version);
7484 return D_O_K;
7485 }
7486
7487 int32_t onDebug()
7488 {
7489 if(debug_enabled)
7490 set_debug(!get_debug());
7491 return D_O_K;
7492 }
7493
7494 int32_t onHeartBeep()
7495 {
7496 heart_beep=!heart_beep;
7497 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7498 return D_O_K;
7499 }
7500
7501 int32_t onSaveIndicator()
7502 {
7503 use_save_indicator=!use_save_indicator;
7504 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7505 return D_O_K;
7506 }
7507
7508 int32_t onEpilepsy()
7509 {
7510 if(jwin_alert3(
7511 "Epilepsy Flash Reduction",
7512 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7513 "Disabling this will restore standard flash and wavy behaviour.",
7514 "Proceed?",
7515 "&Yes",
7516 "&No",
7517 NULL,
7518 'y',
7519 'n',
7520 0,
7521 lfont) == 1)
7522 {
7523 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7524 zc_set_config("zeldadx","checked_epilepsy",1);
7525 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7526 }
7527 return D_O_K;
7528 }
7529
7530 int32_t onTriforce()
7531 {
7532 for(int32_t i=0; i<MAXINITTABS; ++i)
7533 {
7534 init_tabs[i].flags&=~D_SELECTED;
7535 }
7536
7537 init_tabs[3].flags=D_SELECTED;
7538 return onCheatConsole();
7539 /*triforce_dlg[0].dp2=lfont;
7540 for(int32_t i=1; i<=8; i++)
7541 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7542
7543 if(zc_popup_dialog (triforce_dlg,-1)==9)
7544 {
7545 for(int32_t i=1; i<=8; i++)
7546 {
7547 game->lvlitems[i] &= ~liTRIFORCE;
7548 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7549 }
7550 }
7551 return D_O_K;*/
7552 }
7553
7554 bool rc = false;
7555 /*
7556 int32_t onEquipment()
7557 {
7558 for (int32_t i=0; i<MAXINITTABS; ++i)
7559 {
7560 init_tabs[i].flags&=~D_SELECTED;
7561 }
7562 init_tabs[0].flags=D_SELECTED;
7563 return onCheatConsole();
7564 }
7565 */
7566
7567 int32_t onItems()
7568 {
7569 for(int32_t i=0; i<MAXINITTABS; ++i)
7570 {
7571 init_tabs[i].flags&=~D_SELECTED;
7572 }
7573
7574 init_tabs[1].flags=D_SELECTED;
7575 return onCheatConsole();
7576 }
7577
7578 static DIALOG getnum_dlg[] =
7579 {
7580 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7581 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7582 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7583 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7584 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7585 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7586 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7587 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7588 };
7589
7590 int32_t getnumber(const char *prompt,int32_t initialval)
7591 {
7592 char buf[20];
7593 sprintf(buf,"%d",initialval);
7594 getnum_dlg[0].dp=(void *)prompt;
7595 getnum_dlg[0].dp2=lfont;
7596 getnum_dlg[2].dp=buf;
7597
7598 if(is_large)
7599 large_dialog(getnum_dlg);
7600
7601 if(zc_popup_dialog(getnum_dlg,2)==3)
7602 return atoi(buf);
7603
7604 return initialval;
7605 }
7606
7607 int32_t onLife()
7608 {
7609 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7610 cheats_enqueue(Cheat::Life, value);
7611 return D_O_K;
7612 }
7613
7614 int32_t onHeartC()
7615 {
7616 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7617 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7618 cheats_enqueue(Cheat::MaxLife, max_life);
7619 cheats_enqueue(Cheat::Life, life);
7620 return D_O_K;
7621 }
7622
7623 int32_t onMagicC()
7624 {
7625 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7626 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7627 cheats_enqueue(Cheat::MaxMagic, max_magic);
7628 cheats_enqueue(Cheat::Magic, magic);
7629 return D_O_K;
7630 }
7631
7632 int32_t onRupies()
7633 {
7634 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7635 cheats_enqueue(Cheat::Rupies, value);
7636 return D_O_K;
7637 }
7638
7639 int32_t onMaxBombs()
7640 {
7641 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7642 cheats_enqueue(Cheat::MaxBombs, value);
7643 cheats_enqueue(Cheat::Bombs, value);
7644 return D_O_K;
7645 }
7646
7647 int32_t onRefillLife()
7648 {
7649 cheats_enqueue(Cheat::Life, game->get_maxlife());
7650 return D_O_K;
7651 }
7652 int32_t onRefillMagic()
7653 {
7654 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7655 return D_O_K;
7656 }
7657 int32_t onClock()
7658 {
7659 cheats_enqueue(Cheat::Clock);
7660 return D_O_K;
7661 }
7662
7663 int32_t onQstPath()
7664 {
7665 char path[2048];
7666
7667 chop_path(qstdir);
7668 strcpy(path,qstdir);
7669
7670 go();
7671
7672 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7673 {
7674 chop_path(path);
7675 fix_filename_case(path);
7676 fix_filename_slashes(path);
7677 strcpy(qstdir,path);
7678 strcpy(qstpath,qstdir);
7679 }
7680
7681 comeback();
7682 return D_O_K;
7683 }
7684
7685 #include "dialog/cheat_dialog.h"
7686 int32_t onCheat()
7687 {
7688 call_setcheat_dialog();
7689 game->set_cheat(maxcheat);
7690 if(cheat) game->did_cheat(true);
7691 return D_O_K;
7692 }
7693
7694 int32_t onCheatRupies()
7695 {
7696 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7697 return D_O_K;
7698 }
7699
7700 int32_t onCheatArrows()
7701 {
7702 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7703 return D_O_K;
7704 }
7705
7706 int32_t onCheatBombs()
7707 {
7708 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7709 return D_O_K;
7710 }
7711
7712 // *** screen saver
7713
7714 3108180 int32_t after_time()
7715 {
7716
1/2
✓ Branch 0 taken 3108180 times.
✗ Branch 1 not taken.
3108180 if(ss_enable == 0)
7717 return INT_MAX;
7718
7719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3108180 times.
3108180 if(ss_after <= 0)
7720 return 5 * 60;
7721
7722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3108180 times.
3108180 if(ss_after <= 3)
7723 return ss_after * 15 * 60;
7724
7725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3108180 times.
3108180 if(ss_after <= 13)
7726 return (ss_after - 3) * 60 * 60;
7727
7728 3108180 return MAX_IDLE + 1;
7729 3108180 }
7730
7731 static const char *after_str[15] =
7732 {
7733 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7734 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7735 "Never"
7736 };
7737
7738 const char *after_list(int32_t index, int32_t *list_size)
7739 {
7740 if(index < 0)
7741 {
7742 *list_size = 15;
7743 return NULL;
7744 }
7745
7746 return after_str[index];
7747 }
7748
7749 11 static ListData after__list(after_list, &font);
7750
7751 static DIALOG scrsaver_dlg[] =
7752 {
7753 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7754 11 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7755 11 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7756 11 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7757 11 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7758 11 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7759 11 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7760 11 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7761 11 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7762 11 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7763 11 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7764 11 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7765 11 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7766 11 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7767 };
7768
7769 int32_t onScreenSaver()
7770 {
7771 scrsaver_dlg[0].dp2=lfont;
7772 int32_t oldcfgs[3];
7773 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7774 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7775 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7776
7777 if(is_large)
7778 large_dialog(scrsaver_dlg);
7779
7780 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7781
7782 if(ret == 8 || ret == 9)
7783 {
7784 ss_after = scrsaver_dlg[5].d1;
7785 ss_speed = scrsaver_dlg[6].d2;
7786 ss_density = scrsaver_dlg[7].d2;
7787 if(oldcfgs[0] != ss_after)
7788 zc_set_config(cfg_sect,"ss_after",ss_after);
7789 if(oldcfgs[1] != ss_speed)
7790 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7791 if(oldcfgs[2] != ss_density)
7792 zc_set_config(cfg_sect,"ss_density",ss_density);
7793 }
7794
7795 if(ret == 9)
7796 // preview Screen Saver
7797 {
7798 clear_keybuf();
7799 scare_mouse();
7800 Matrix(ss_speed, ss_density, 30);
7801 system_pal();
7802 unscare_mouse();
7803 }
7804
7805 return D_O_K;
7806 }
7807
7808 /***** Menus *****/
7809
7810 static MENU game_menu[] =
7811 {
7812 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7813 { (char *)"", NULL, NULL, 0, NULL },
7814 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7815 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7816 { (char *)"", NULL, NULL, 0, NULL },
7817 #ifdef __EMSCRIPTEN__
7818 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7819 #elif defined(ALLEGRO_MACOSX)
7820 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7821 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7822 #else
7823 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7824 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7825 #endif
7826 { NULL, NULL, NULL, 0, NULL }
7827 };
7828
7829 static MENU title_menu[] =
7830 {
7831 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7832 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7833 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7834 { NULL, NULL, NULL, 0, NULL }
7835 };
7836
7837 static MENU snapshot_format_menu[] =
7838 {
7839 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7840 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7841 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7842 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7843 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7844 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7845 { NULL, NULL, NULL, 0, NULL }
7846 };
7847
7848 static MENU controls_menu[] =
7849 {
7850 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7851 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7852 { NULL, NULL, NULL, 0, NULL }
7853 };
7854
7855 static MENU name_entry_mode_menu[] =
7856 {
7857 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7858 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7859 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7860 { NULL, NULL, NULL, 0, NULL }
7861 };
7862
7863 static void set_controls_menu_active()
7864 {
7865
7866 }
7867
7868 static MENU settings_menu[] =
7869 {
7870 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7871 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7872 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7873 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7874 { (char *)"", NULL, NULL, 0, NULL },
7875 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7876 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7877 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7878 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7879 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7880 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7881 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7882 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7883 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7884 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7885 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7886 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7887 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7888 { (char *)"", NULL, NULL, 0, NULL },
7889 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7890 { (char *)"", NULL, NULL, 0, NULL },
7891 { NULL, NULL, NULL, 0, NULL }
7892 };
7893
7894
7895 static MENU misc_menu[] =
7896 {
7897 { (char *)"&About...", onAbout, NULL, 0, NULL },
7898 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7899 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7900 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7901 { (char *)"", NULL, NULL, 0, NULL },
7902 //5
7903 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7904 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7905 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7906 { (char *)"", NULL, NULL, 0, NULL },
7907 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7908 //10
7909 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7910 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7911 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7912 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7913 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7914 //15
7915 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7916 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7917 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7918
7919 { NULL, NULL, NULL, 0, NULL }
7920 };
7921
7922 static MENU refill_menu[] =
7923 {
7924 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7925 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7926 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7927 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7928 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7929 { NULL, NULL, NULL, 0, NULL }
7930 };
7931
7932 static MENU show_menu[] =
7933 {
7934 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7935 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7936 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7937 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7938 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7939 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7940 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7941 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7942 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7943 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7944 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7945 { (char *)"", NULL, NULL, 0, NULL },
7946 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7947 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7948 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7949 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7950 { NULL, NULL, NULL, 0, NULL }
7951 };
7952
7953 static MENU cheat_menu[] =
7954 {
7955 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7956 { (char *)"", NULL, NULL, 0, NULL },
7957 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7958 { (char *)"", NULL, NULL, 0, NULL },
7959 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7960 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7961 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7962 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7963 { (char *)"", NULL, NULL, 0, NULL },
7964 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7965 { (char *)"", NULL, NULL, 0, NULL },
7966 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7967 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7968 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7969 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7970 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7971 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7972 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7973 { NULL, NULL, NULL, 0, NULL }
7974 };
7975
7976 static MENU fixes_menu[] =
7977 {
7978 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7979 { NULL, NULL, NULL, 0, NULL }
7980 };
7981
7982 #if DEVLEVEL > 0
7983 int32_t devLogging();
7984 int32_t devDebug();
7985 int32_t devTimestmp();
7986 #if DEVLEVEL > 1
7987 int32_t setCheat();
7988 #endif //DEVLEVEL > 1
7989 enum
7990 {
7991 dv_log,
7992 // dv_dbg,
7993 dv_tmpstmp,
7994 #if DEVLEVEL > 1
7995 dv_nil,
7996 dv_setcheat,
7997 #endif //DEVLEVEL > 1
7998 dv_max
7999 };
8000 static MENU dev_menu[] =
8001 {
8002 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
8003 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
8004 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
8005 #if DEVLEVEL > 1
8006 { (char *)"", NULL, NULL, 0, NULL },
8007 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
8008 #endif //DEVLEVEL > 1
8009 { NULL, NULL, NULL, 0, NULL }
8010 };
8011 int32_t devLogging()
8012 {
8013 dev_logging = !dev_logging;
8014 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
8015 return D_O_K;
8016 }
8017 // int32_t devDebug()
8018 // {
8019 // dev_debug = !dev_debug;
8020 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
8021 // return D_O_K;
8022 // }
8023 int32_t devTimestmp()
8024 {
8025 dev_timestmp = !dev_timestmp;
8026 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
8027 return D_O_K;
8028 }
8029 #if DEVLEVEL > 1
8030 int32_t setCheat()
8031 {
8032 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8033 return D_O_K;
8034 }
8035 #endif //DEVLEVEL > 1
8036 #endif //DEVLEVEL > 0
8037
8038 MENU the_player_menu[] =
8039 {
8040 { (char *)"&Game", NULL, game_menu, 0, NULL },
8041 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8042 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8043 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8044 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8045 #if DEVLEVEL > 0
8046 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8047 #endif
8048 { NULL, NULL, NULL, 0, NULL }
8049 };
8050
8051 MENU the_player_menu2[] =
8052 {
8053 { (char *)"&Game", NULL, game_menu, 0, NULL },
8054 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8055 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8056 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8057 #if DEVLEVEL > 0
8058 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8059 #endif
8060 { NULL, NULL, NULL, 0, NULL }
8061 };
8062
8063 int32_t onMIDIPatch()
8064 {
8065 if(jwin_alert3(
8066 "Toggle Windows MIDI Fix",
8067 "This action will change whether ZC Player auto-restarts a MIDI at its",
8068 "last index if you move ZC Player out of focus, then back into focus.",
8069 "Proceed?",
8070 "&Yes",
8071 "&No",
8072 NULL,
8073 'y',
8074 'n',
8075 0,
8076 lfont) == 1)
8077 {
8078 midi_patch_fix = midi_patch_fix ? 0 : 1;
8079 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
8080 }
8081 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8082 return D_O_K;
8083 }
8084
8085 int32_t onKeyboardEntry()
8086 {
8087 NameEntryMode=0;
8088 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8089 return D_O_K;
8090 }
8091
8092 int32_t onLetterGridEntry()
8093 {
8094 NameEntryMode=1;
8095 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8096 return D_O_K;
8097 }
8098
8099 int32_t onExtLetterGridEntry()
8100 {
8101 NameEntryMode=2;
8102 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8103 return D_O_K;
8104 }
8105
8106 static BITMAP* oldscreen;
8107 int32_t onFullscreenMenu()
8108 {
8109 // super hacks
8110 screen = oldscreen;
8111 if (onFullscreen() == D_REDRAW)
8112 {
8113 oldscreen = screen;
8114 }
8115 screen = menu_bmp;
8116 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8117 return D_O_K;
8118 }
8119
8120 11 void fix_menu()
8121 {
8122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!debug_enabled)
8123 11 settings_menu[18].text = NULL;
8124 11 }
8125
8126 static DIALOG system_dlg[] =
8127 {
8128 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8129 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8130 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8131 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8132 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8133 #ifndef ALLEGRO_MACOSX
8134 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8135 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8136 #else
8137 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8138 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8139 #endif
8140 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8141 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8142 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8143 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8144 };
8145
8146 static DIALOG system_dlg2[] =
8147 {
8148 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8149 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8150 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8151 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8152 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8153 #ifndef ALLEGRO_MACOSX
8154 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8155 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8156 #else
8157 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8158 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8159 #endif
8160 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8161 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8162 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8163 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8164 };
8165
8166 void reset_snapshot_format_menu()
8167 {
8168 for(int32_t i=0; i<ssfmtMAX; ++i)
8169 {
8170 snapshot_format_menu[i].flags=0;
8171 }
8172 }
8173
8174 int32_t onSetSnapshotFormat()
8175 {
8176 switch(active_menu->text[1])
8177 {
8178 case 'B': //"&BMP"
8179 SnapshotFormat=0;
8180 break;
8181
8182 case 'G': //"&GIF"
8183 SnapshotFormat=1;
8184 break;
8185
8186 case 'J': //"&JPG"
8187 SnapshotFormat=2;
8188 break;
8189
8190 case 'P': //"&PNG"
8191 SnapshotFormat=3;
8192 break;
8193
8194 case 'C': //"PC&X"
8195 SnapshotFormat=4;
8196 break;
8197
8198 case 'T': //"&TGA"
8199 SnapshotFormat=5;
8200 break;
8201
8202 case 'L': //"&LBM"
8203 SnapshotFormat=6;
8204 break;
8205 }
8206 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
8207
8208 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8209 return D_O_K;
8210 }
8211
8212
8213 12 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8214 {
8215 PALETTE tmp;
8216
8217
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<256; i++)
8218 {
8219 3072 tmp[i].r=r;
8220 3072 tmp[i].g=g;
8221 3072 tmp[i].b=b;
8222 3072 }
8223
8224 12 fade_interpolate(src,tmp,dest,pos,from,to);
8225 12 }
8226
8227 12 void system_pal()
8228 {
8229 12 is_sys_pal = true;
8230 static PALETTE pal;
8231 12 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8232
8233 // set up the grayscale palette
8234
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 12 times.
780 for(int32_t i=128; i<192; i++)
8235 {
8236 768 pal[i].r = i-128;
8237 768 pal[i].g = i-128;
8238 768 pal[i].b = i-128;
8239 768 }
8240 12 load_colorset(gui_colorset, pal);
8241
8242 12 color_layer(pal, pal, 24,16,16, 28, 128,191);
8243
8244
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 12 times.
1548 for(int32_t i=0; i<256; i+=2)
8245 {
8246 1536 int32_t v = (i>>3)+2;
8247 1536 int32_t c = (i>>3)+192;
8248 1536 pal[c] = _RGB(v,v,v+(v>>1));
8249 /*
8250 if(i<240)
8251 {
8252 _allegro_hline(tmp_scr,0,i,319,c);
8253 _allegro_hline(tmp_scr,0,i+1,319,c);
8254 }
8255 */
8256 1536 }
8257
8258 // draw the vertical screen gradient
8259
2/2
✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 12 times.
2892 for(int32_t i=0; i<240; ++i)
8260 {
8261 2880 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8262 2880 }
8263
8264 /*
8265 palrstart= 10*63/255; palrend=166*63/255;
8266 palgstart= 36*63/255; palgend=202*63/255;
8267 palbstart=106*63/255; palbend=240*63/255;
8268 paldivs=32;
8269 for(int32_t i=0; i<paldivs; i++)
8270 {
8271 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8272 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8273 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8274 }
8275 */
8276 12 BITMAP *panorama = create_bitmap_ex(8,256,224);
8277 int32_t ts_height, ts_start;
8278
8279
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8280 {
8281 clear_to_color(panorama,0);
8282 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8283 ts_height=224-passive_subscreen_height;
8284 ts_start=28;
8285 }
8286 else
8287 {
8288 12 blit(framebuf,panorama,0,0,0,0,256,224);
8289 12 ts_height=224;
8290 12 ts_start=0;
8291 }
8292
8293 // gray scale the current frame
8294
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 12 times.
2700 for(int32_t y=0; y<ts_height; y++)
8295 {
8296
2/2
✓ Branch 0 taken 688128 times.
✓ Branch 1 taken 2688 times.
690816 for(int32_t x=0; x<256; x++)
8297 {
8298 688128 int32_t c = panorama->line[y+ts_start][x];
8299
2/2
✓ Branch 0 taken 687647 times.
✓ Branch 1 taken 481 times.
688128 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8300 688128 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8301 688128 }
8302 2688 }
8303
8304 12 destroy_bitmap(panorama);
8305
8306 // display everything
8307 12 vsync();
8308 12 hw_palette = &pal;
8309 12 update_hw_pal = true;
8310
8311 // sys_pal = pal;
8312 12 memcpy(sys_pal,pal,sizeof(pal));
8313 12 }
8314
8315 void system_pal2()
8316 {
8317 is_sys_pal = true;
8318 static PALETTE RAMpal2;
8319 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8320
8321 /* Windows 2000 colors
8322 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8323 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8324 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8325 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8326 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8327 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8328 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8329 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8330
8331 byte palrstart= 10*63/255, palrend=166*63/255,
8332 palgstart= 36*63/255, palgend=202*63/255,
8333 palbstart=106*63/255, palbend=240*63/255,
8334 paldivs=7;
8335 for(int32_t i=0; i<paldivs; i++)
8336 {
8337 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8338 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8339 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8340 }
8341 */
8342
8343 /* Windows 98 colors
8344 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8345 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8346 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8347 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8348 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8349 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8350 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8351 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8352
8353 byte palrstart= 0*63/255, palrend=166*63/255,
8354 palgstart= 0*63/255, palgend=202*63/255,
8355 palbstart=128*63/255, palbend=240*63/255,
8356 paldivs=7;
8357 for(int32_t i=0; i<paldivs; i++)
8358 {
8359 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8360 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8361 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8362 }
8363 */
8364
8365 /* Windows 99 colors
8366 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8367 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8368 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8369 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8370 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8371 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8372 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8373 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8374 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8375
8376 byte palrstart= 0*63/255, palrend=166*63/255,
8377 palgstart= 0*63/255, palgend=202*63/255,
8378
8379 palbstart=128*63/255, palbend=240*63/255,
8380 paldivs=6;
8381 for(int32_t i=0; i<paldivs; i++)
8382 {
8383 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8384 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8385 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8386 }
8387 */
8388
8389
8390
8391 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8392 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8393 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8394 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8395 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8396 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8397 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8398 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8399 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8400
8401 byte palrstart= 0*63/255, palrend=166*63/255,
8402 palgstart= 0*63/255, palgend=202*63/255,
8403 palbstart=128*63/255, palbend=240*63/255,
8404 paldivs=6;
8405
8406 for(int32_t i=0; i<paldivs; i++)
8407 {
8408 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8409 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8410 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8411 }
8412
8413 gui_bg_color=jwin_pal[jcBOX];
8414 gui_fg_color=jwin_pal[jcBOXFG];
8415
8416 jwin_set_colors(jwin_pal);
8417
8418
8419 // set up the new palette
8420 for(int32_t i=128; i<192; i++)
8421 {
8422 RAMpal2[i].r = i-128;
8423 RAMpal2[i].g = i-128;
8424 RAMpal2[i].b = i-128;
8425 }
8426
8427 /*
8428 for(int32_t i=0; i<64; i++)
8429 {
8430 RAMpal2[128+i] = _RGB(i,i,i)1));
8431 }
8432 */
8433
8434 /*
8435
8436 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8437 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8438 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8439 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8440 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8441 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8442 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8443
8444 gui_fg_color=vc(14);
8445 gui_bg_color=vc(1);
8446
8447 jwin_set_colors(jwin_pal);
8448 */
8449
8450 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8451
8452 // set up the colors for the vertical screen gradient
8453 for(int32_t i=0; i<256; i+=2)
8454 {
8455 int32_t v = (i>>3)+2;
8456 int32_t c = (i>>3)+192;
8457 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8458
8459 /*
8460 if(i<240)
8461 {
8462 _allegro_hline(tmp_scr,0,i,319,c);
8463 _allegro_hline(tmp_scr,0,i+1,319,c);
8464 }
8465 */
8466 }
8467
8468 // hw_palette = &RAMpal;
8469 // update_hw_pal = true;
8470
8471 for(int32_t i=0; i<240; ++i)
8472 {
8473 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8474 }
8475
8476 /*
8477 byte palrstart= 10*63/255, palrend=166*63/255,
8478 palgstart= 36*63/255, palgend=202*63/255,
8479 palbstart=106*63/255, palbend=240*63/255,
8480 paldivs=32;
8481 for(int32_t i=0; i<paldivs; i++)
8482 {
8483 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8484 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8485 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8486 }
8487 */
8488 BITMAP *panorama = create_bitmap_ex(8,256,224);
8489 int32_t ts_height, ts_start;
8490
8491 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8492 {
8493 clear_to_color(panorama,0);
8494 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8495 ts_height=224-passive_subscreen_height;
8496 ts_start=28;
8497 }
8498 else
8499 {
8500 blit(framebuf,panorama,0,0,0,0,256,224);
8501 ts_height=224;
8502 ts_start=0;
8503 }
8504
8505 // gray scale the current frame
8506 for(int32_t y=0; y<ts_height; y++)
8507 {
8508 for(int32_t x=0; x<256; x++)
8509 {
8510 int32_t c = panorama->line[y+ts_start][x];
8511 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8512 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8513 }
8514 }
8515
8516 destroy_bitmap(panorama);
8517
8518 // display everything
8519 vsync();
8520 hw_palette = &RAMpal2;
8521 update_hw_pal = true;
8522
8523 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8524
8525 // sys_pal = pal;
8526 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8527 }
8528
8529 static uint32_t entered_sys_pal = 0;
8530 1 void enter_sys_pal()
8531 {
8532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(is_sys_pal)
8533 {
8534 if(entered_sys_pal)
8535 ++entered_sys_pal;
8536 return;
8537 }
8538 1 system_pal();
8539 1 ++entered_sys_pal;
8540 1 }
8541 1 void exit_sys_pal()
8542 {
8543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(entered_sys_pal)
8544 {
8545
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!--entered_sys_pal)
8546 {
8547 1 game_pal();
8548 1 }
8549 1 }
8550 1 }
8551
8552 1 void switch_out_callback()
8553 {
8554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (pause_in_background)
8555 {
8556 callback_switchin = 3;
8557 return;
8558 }
8559
8560 #ifdef _WIN32
8561 if(midi_patch_fix==0 || currmidi==-1)
8562 return;
8563
8564
8565 paused_midi_pos = midi_pos;
8566 zc_stop_midi();
8567 midi_paused=true;
8568 midi_suspended = midissuspHALTED;
8569 #endif
8570 1 }
8571
8572 void switch_in_callback()
8573 {
8574 if(pause_in_background)
8575 {
8576 return;
8577 }
8578
8579 #ifdef _WIN32
8580 if(midi_patch_fix==0 || currmidi==-1)
8581 return;
8582
8583 else
8584 {
8585 callback_switchin = 1;
8586 midi_suspended = midissuspRESUME;
8587 }
8588 #endif
8589 }
8590
8591 109 void game_pal()
8592 {
8593 109 is_sys_pal = false;
8594 109 entered_sys_pal = 0;
8595 109 clear_to_color(screen,BLACK);
8596 109 hw_palette = &RAMpal;
8597 109 update_hw_pal = true;
8598 109 }
8599
8600 static char bar_str[] = "";
8601
8602 1 void music_pause()
8603 {
8604 //al_pause_duh(tmplayer);
8605 1 zcmusic_pause(zcmusic, ZCM_PAUSE);
8606 1 zc_midi_pause();
8607 1 midi_paused=true;
8608 1 }
8609
8610 void music_resume()
8611 {
8612 //al_resume_duh(tmplayer);
8613 zcmusic_pause(zcmusic, ZCM_RESUME);
8614 zc_midi_resume();
8615 midi_paused=false;
8616 }
8617
8618 2237 void music_stop()
8619 {
8620 //al_stop_duh(tmplayer);
8621 //unload_duh(tmusic);
8622 //tmusic=NULL;
8623 //tmplayer=NULL;
8624 2237 zcmusic_stop(zcmusic);
8625 2237 zcmusic_unload_file(zcmusic);
8626 2237 zc_stop_midi();
8627 2237 midi_paused=false;
8628 2237 currmidi=-1;
8629 2237 }
8630
8631 void System()
8632 {
8633 mouse_down=gui_mouse_b();
8634 music_pause();
8635 pause_all_sfx();
8636 MenuOpen = true;
8637 system_pal();
8638 // FONT *oldfont=font;
8639 // font=tfont;
8640
8641 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8642 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8643
8644 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8645 #if DEVLEVEL > 1
8646 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8647 #endif
8648 game_menu[3].flags =
8649 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8650 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8651 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8652 clear_keybuf();
8653 show_mouse(screen);
8654
8655 DIALOG_PLAYER *p;
8656
8657 clear_bitmap(menu_bmp);
8658 oldscreen = screen;
8659 screen = menu_bmp;
8660
8661 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8662 {
8663 p = init_dialog(system_dlg2,-1);
8664 }
8665 else
8666 {
8667 p = init_dialog(system_dlg,-1);
8668 }
8669
8670 // drop the menu on startup if menu button pressed
8671 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8672 simulate_keypress(KEY_G << 8);
8673
8674 do
8675 {
8676 if(close_button_quit)
8677 {
8678 close_button_quit = false;
8679 f_Quit(qEXIT);
8680 if(Quit) break;
8681 }
8682 rest(17);
8683
8684 if(mouse_down && !gui_mouse_b())
8685 mouse_down=0;
8686
8687 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8688 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8689 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8690
8691 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8692 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8693 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8694 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8695 settings_menu[8].flags = NESquit?D_SELECTED:0;
8696 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8697 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8698 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8699 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8700 settings_menu[13].flags = volkeys?D_SELECTED:0;
8701 //Epilepsy Prevention
8702 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8703
8704 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8705 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8706 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8707
8708 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8709 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8710 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8711
8712 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8713 cheat_menu[0].flags = 0;
8714 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8715 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8716 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8717 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8718 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8719 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8720 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8721 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8722 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8723
8724 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8725 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8726 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8727 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8728 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8729 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8730 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8731 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8732 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8733 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8734 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8735 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8736 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8737 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8738 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8739
8740 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8741 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8742
8743 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8744 (char *)"Disable recording new saves" :
8745 (char *)"Enable recording new saves";
8746 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8747 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8748 (char *)"Stop recording" :
8749 (char *)"Stop replaying";
8750 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8751
8752 reset_snapshot_format_menu();
8753 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8754
8755 if(debug_enabled)
8756 {
8757 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8758 }
8759
8760 if(gui_mouse_b() && !mouse_down)
8761 break;
8762
8763 // press menu to drop the menu
8764 if(rMbtn())
8765 simulate_keypress(KEY_G << 8);
8766
8767 if(input_idle(true) > after_time())
8768 // run Screeen Saver
8769 {
8770 // Screen saver enabled for now.
8771 clear_keybuf();
8772 scare_mouse();
8773 Matrix(ss_speed, ss_density, 0);
8774 system_pal();
8775 unscare_mouse();
8776 broadcast_dialog_message(MSG_DRAW, 0);
8777 }
8778
8779 update_hw_screen();
8780 }
8781 while(update_dialog(p));
8782
8783 screen = oldscreen;
8784
8785 // font=oldfont;
8786 mouse_down=gui_mouse_b();
8787 shutdown_dialog(p);
8788 show_mouse(NULL);
8789 MenuOpen = false;
8790 if(Quit)
8791 {
8792 kill_sfx();
8793 music_stop();
8794 update_hw_screen();
8795 }
8796 else
8797 {
8798 game_pal();
8799 music_resume();
8800 resume_all_sfx();
8801
8802 if(rc)
8803 ringcolor(false);
8804 }
8805
8806 eat_buttons();
8807
8808 rc=false;
8809 clear_keybuf();
8810 // text_mode(0);
8811 }
8812
8813 11 void fix_dialogs()
8814 {
8815 11 jwin_center_dialog(about_dlg);
8816 11 jwin_center_dialog(gamepad_dlg);
8817 11 jwin_center_dialog(credits_dlg);
8818 11 jwin_center_dialog(gamemode_dlg);
8819 11 jwin_center_dialog(getnum_dlg);
8820 11 jwin_center_dialog(goto_dlg);
8821 11 jwin_center_dialog(keyboard_control_dlg);
8822 11 jwin_center_dialog(midi_dlg);
8823 11 jwin_center_dialog(quest_dlg);
8824 11 jwin_center_dialog(scrsaver_dlg);
8825 11 jwin_center_dialog(sound_dlg);
8826 11 jwin_center_dialog(triforce_dlg);
8827
8828 // digi_dp[1] += scrx;
8829 // digi_dp[2] += scry;
8830 // midi_dp[1] += scrx;
8831 // midi_dp[2] += scry;
8832 // pan_dp[1] += scrx;
8833 // pan_dp[2] += scry;
8834 // emus_dp[1] += scrx;
8835 // emus_dp[2] += scry;
8836 // buf_dp[1] += scrx;
8837 // buf_dp[2] += scry;
8838 // sfx_dp[1] += scrx;
8839 // sfx_dp[2] += scry;
8840 11 }
8841
8842 /*****************************/
8843 /**** Custom Sound System ****/
8844 /*****************************/
8845
8846 1035 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8847 {
8848
3/4
✓ Branch 0 taken 977 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 1035 times.
✗ Branch 3 not taken.
1035 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8849 }
8850
8851 // Run an NSF, or a MIDI if the NSF is missing somehow.
8852 33 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8853 {
8854 33 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8855
8856 // Found it
8857
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(newzcmusic!=NULL)
8858 {
8859 33 zcmusic_stop(zcmusic);
8860 33 zcmusic_unload_file(zcmusic);
8861 33 zc_stop_midi();
8862
8863 33 zcmusic=newzcmusic;
8864 33 zcmusic_play(zcmusic, emusic_volume);
8865
8866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(track>0)
8867 33 zcmusic_change_track(zcmusic,track);
8868
8869 33 return true;
8870 }
8871
8872 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8873 else if(midi>-1000)
8874 jukebox(midi);
8875
8876 return false;
8877 33 }
8878
8879 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8880 {
8881 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8882 // Found it
8883 if(newzcmusic!=NULL)
8884 {
8885 zcmusic_stop(zcmusic);
8886 zcmusic_unload_file(zcmusic);
8887 zc_stop_midi();
8888
8889 zcmusic=newzcmusic;
8890 zcmusic_play(zcmusic, emusic_volume);
8891
8892 if(track>0)
8893 zcmusic_change_track(zcmusic,track);
8894
8895 return true;
8896 }
8897
8898 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8899 else if(midi>-1000)
8900 jukebox(midi);
8901
8902 return false;
8903 }
8904
8905 int32_t get_zcmusicpos()
8906 {
8907 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8908 return debugtracething;
8909 return 0;
8910 }
8911
8912 void set_zcmusicpos(int32_t position)
8913 {
8914 zcmusic_set_curpos(zcmusic, position);
8915 }
8916
8917 void set_zcmusicspeed(int32_t speed)
8918 {
8919 int32_t newspeed = vbound(speed, 0, 10000);
8920 zcmusic_set_speed(zcmusic, newspeed);
8921 }
8922
8923 512 void jukebox(int32_t index,int32_t loop)
8924 {
8925 512 music_stop();
8926
8927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 if(index<0) index=MAXMIDIS-1;
8928
8929
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(index>=MAXMIDIS) index=0;
8930
8931 512 music_stop();
8932
8933 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8934 // stuck notes when a song stops. This fixes it.
8935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 if(strcmp(midi_driver->name, "DIGMID")==0)
8936 zc_set_volume(0, 0);
8937
8938 512 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8939 512 zc_play_midi((MIDI*)tunes[index].data,loop);
8940
8941
2/2
✓ Branch 0 taken 374 times.
✓ Branch 1 taken 138 times.
512 if(tunes[index].start>0)
8942 138 zc_midi_seek(tunes[index].start);
8943
8944 512 midi_loop_start = tunes[index].loop_start;
8945 512 midi_loop_end = tunes[index].loop_end;
8946
8947 512 currmidi=index;
8948 512 master_volume(digi_volume,midi_volume);
8949 512 midi_paused=false;
8950 512 }
8951
8952 3518 void jukebox(int32_t index)
8953 {
8954
1/2
✓ Branch 0 taken 3518 times.
✗ Branch 1 not taken.
3518 if(index<0) index=MAXMIDIS-1;
8955
8956
1/2
✓ Branch 0 taken 3518 times.
✗ Branch 1 not taken.
3518 if(index>=MAXMIDIS) index=0;
8957
8958 // do nothing if it's already playing
8959
3/4
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 3006 times.
✗ Branch 3 not taken.
3518 if(index==currmidi && midi_pos>=0)
8960 {
8961 3006 midi_paused=false;
8962 3006 return;
8963 }
8964
8965 512 jukebox(index,tunes[index].loop);
8966 3518 }
8967
8968 3888 void play_DmapMusic()
8969 {
8970 static char tfile[2048];
8971 static int32_t ttrack=0;
8972 3888 bool domidi=false;
8973
8974
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 3417 times.
3888 if(DMaps[currdmap].tmusic[0]!=0)
8975 {
8976
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
856 if(zcmusic==NULL ||
8977
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8978
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8979 {
8980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(zcmusic != NULL)
8981 {
8982 zcmusic_stop(zcmusic);
8983 zcmusic_unload_file(zcmusic);
8984 zcmusic = NULL;
8985 }
8986
8987 86 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8988
8989
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(zcmusic!=NULL)
8990 {
8991 86 zc_stop_midi();
8992 86 strcpy(tfile,DMaps[currdmap].tmusic);
8993 86 zcmusic_play(zcmusic, emusic_volume);
8994 86 int32_t temptracks=0;
8995 86 temptracks=zcmusic_get_tracks(zcmusic);
8996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8997 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8998 86 zcmusic_change_track(zcmusic,ttrack);
8999 86 }
9000 else
9001 {
9002 tfile[0] = 0;
9003 domidi=true;
9004 }
9005 86 }
9006 471 }
9007 else
9008 {
9009 3417 domidi=true;
9010 }
9011
9012
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 3417 times.
3888 if(domidi)
9013 {
9014 3417 int32_t m=DMaps[currdmap].midi;
9015
9016
3/4
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
3417 switch(m)
9017 {
9018 case 1:
9019 80 jukebox(ZC_MIDI_OVERWORLD);
9020 80 break;
9021
9022 case 2:
9023 9 jukebox(ZC_MIDI_DUNGEON);
9024 9 break;
9025
9026 case 3:
9027 jukebox(ZC_MIDI_LEVEL9);
9028 break;
9029
9030 default:
9031
3/4
✓ Branch 0 taken 3318 times.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3318 times.
3328 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9032 3318 jukebox(m+MIDIOFFSET_DMAP);
9033 else
9034 10 music_stop();
9035 3328 }
9036 3417 }
9037 3888 }
9038
9039 3936 void playLevelMusic()
9040 {
9041 3936 int32_t m=tmpscr->screen_midi;
9042
9043
3/6
✓ Branch 0 taken 3888 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
3936 switch(m)
9044 {
9045 case -2:
9046 11 music_stop();
9047 11 break;
9048
9049 case -1:
9050 3888 play_DmapMusic();
9051 3888 break;
9052
9053 case 1:
9054 jukebox(ZC_MIDI_OVERWORLD);
9055 break;
9056
9057 case 2:
9058 jukebox(ZC_MIDI_DUNGEON);
9059 break;
9060
9061 case 3:
9062 jukebox(ZC_MIDI_LEVEL9);
9063 break;
9064
9065 default:
9066
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9067 37 jukebox(m+MIDIOFFSET_MAPSCR);
9068 else
9069 music_stop();
9070 37 }
9071 3936 }
9072
9073 523 void master_volume(int32_t dv,int32_t mv)
9074 {
9075
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 523 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 523 times.
✗ Branch 7 not taken.
523 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9076
9077
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 523 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 523 times.
✗ Branch 7 not taken.
523 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9078
9079
6/6
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 522 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 509 times.
✓ Branch 5 taken 13 times.
523 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9080 523 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9081 523 }
9082
9083 /*****************/
9084 /***** SFX *****/
9085 /*****************/
9086
9087 // array of voices, one for each sfx sample in the data file
9088 // 0+ = voice #
9089 // -1 = voice not allocated
9090 11 void Z_init_sound()
9091 {
9092
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<WAV_COUNT; i++)
9093 2816 sfx_voice[i]=-1;
9094
9095
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 11 times.
88 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9096 77 tunes[i].data = (MIDI*)mididata[i].dat;
9097
9098
2/2
✓ Branch 0 taken 2772 times.
✓ Branch 1 taken 11 times.
2783 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9099 2772 tunes[ZC_MIDI_COUNT+j].data=NULL;
9100
9101 11 master_volume(digi_volume,midi_volume);
9102 11 }
9103
9104 // returns number of voices currently allocated
9105 int32_t sfx_count()
9106 {
9107 int32_t c=0;
9108
9109 for(int32_t i=0; i<WAV_COUNT; i++)
9110 if(sfx_voice[i]!=-1)
9111 ++c;
9112
9113 return c;
9114 }
9115
9116 // clean up finished samples
9117 3060800 void sfx_cleanup()
9118 {
9119
2/2
✓ Branch 0 taken 783564800 times.
✓ Branch 1 taken 3060800 times.
786625600 for(int32_t i=0; i<WAV_COUNT; i++)
9120
4/4
✓ Branch 0 taken 9665112 times.
✓ Branch 1 taken 773899688 times.
✓ Branch 2 taken 9638969 times.
✓ Branch 3 taken 26143 times.
783590943 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9121 {
9122 26143 deallocate_voice(sfx_voice[i]);
9123 26143 sfx_voice[i]=-1;
9124 26143 }
9125 3060800 }
9126
9127 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9128 // if a voice is already allocated (and/or playing), then it just returns true
9129 // Returns true: voice is allocated
9130 // false: unsuccessful
9131 362312 bool sfx_init(int32_t index)
9132 {
9133 // check index
9134
3/4
✓ Branch 0 taken 326576 times.
✓ Branch 1 taken 35736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 326576 times.
362312 if(index<=0 || index>=WAV_COUNT)
9135 35736 return false;
9136
9137
2/2
✓ Branch 0 taken 294006 times.
✓ Branch 1 taken 32570 times.
326576 if(sfx_voice[index]==-1)
9138 {
9139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32570 times.
32570 if(sfxdat)
9140 {
9141 if(index<Z35)
9142 {
9143 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9144 }
9145 else
9146 {
9147 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9148 }
9149 }
9150 else
9151 {
9152 32570 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9153 }
9154
9155 32570 voice_set_volume(sfx_voice[index], sfx_volume);
9156 32570 }
9157
9158 326576 return sfx_voice[index] != -1;
9159 362312 }
9160
9161 // plays an sfx sample
9162 317697 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9163 {
9164
2/2
✓ Branch 0 taken 298945 times.
✓ Branch 1 taken 18752 times.
317697 if(!sfx_init(index))
9165 18752 return;
9166
9167 298945 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9168 298945 voice_set_pan(sfx_voice[index],pan);
9169
9170 298945 int32_t pos = voice_get_position(sfx_voice[index]);
9171
9172
2/2
✓ Branch 0 taken 164503 times.
✓ Branch 1 taken 134442 times.
298945 if(restart) voice_set_position(sfx_voice[index],0);
9173
9174
2/2
✓ Branch 0 taken 151544 times.
✓ Branch 1 taken 147401 times.
298945 if(pos<=0)
9175 151544 voice_start(sfx_voice[index]);
9176 317697 }
9177
9178 // true if sfx is allocated
9179 4 bool sfx_allocated(int32_t index)
9180 {
9181
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9182 }
9183
9184 // start it (in loop mode) if it's not already playing,
9185 // otherwise adjust it to play in loop mode -DD
9186 44615 void cont_sfx(int32_t index)
9187 {
9188
2/2
✓ Branch 0 taken 16984 times.
✓ Branch 1 taken 27631 times.
44615 if(!sfx_init(index))
9189 {
9190 16984 return;
9191 }
9192
9193
2/2
✓ Branch 0 taken 2238 times.
✓ Branch 1 taken 25393 times.
27631 if(voice_get_position(sfx_voice[index])<=0)
9194 {
9195 2238 voice_set_position(sfx_voice[index],0);
9196 2238 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9197 2238 voice_start(sfx_voice[index]);
9198 2238 }
9199 else
9200 {
9201 25393 adjust_sfx(index, 128, true);
9202 }
9203 44615 }
9204
9205 // adjust parameters while playing
9206 27311 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9207 {
9208
5/6
✓ Branch 0 taken 26329 times.
✓ Branch 1 taken 982 times.
✓ Branch 2 taken 26329 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25561 times.
✓ Branch 5 taken 768 times.
27311 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9209 1750 return;
9210
9211 25561 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9212 25561 voice_set_pan(sfx_voice[index],pan);
9213 27311 }
9214
9215 // pauses a voice
9216 592 void pause_sfx(int32_t index)
9217 {
9218
4/6
✓ Branch 0 taken 592 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 592 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 578 times.
592 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9219 14 voice_stop(sfx_voice[index]);
9220 592 }
9221
9222 // resumes a voice
9223 275 void resume_sfx(int32_t index)
9224 {
9225
3/6
✓ Branch 0 taken 275 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 275 times.
275 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9226 voice_start(sfx_voice[index]);
9227 275 }
9228
9229 // pauses all active voices
9230 2 void pause_all_sfx()
9231 {
9232
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t i=0; i<WAV_COUNT; i++)
9233
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 2 times.
514 if(sfx_voice[i]!=-1)
9234 2 voice_stop(sfx_voice[i]);
9235 2 }
9236
9237 // resumes all paused voices
9238 1 void resume_all_sfx()
9239 {
9240
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<WAV_COUNT; i++)
9241
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(sfx_voice[i]!=-1)
9242 voice_start(sfx_voice[i]);
9243 1 }
9244
9245 // stops an sfx and deallocates the voice
9246 2480588 void stop_sfx(int32_t index)
9247 {
9248
3/4
✓ Branch 0 taken 2473879 times.
✓ Branch 1 taken 6709 times.
✓ Branch 2 taken 2473879 times.
✗ Branch 3 not taken.
2480588 if(index<=0 || index>=WAV_COUNT)
9249 6709 return;
9250
9251
2/2
✓ Branch 0 taken 4849 times.
✓ Branch 1 taken 2469030 times.
2473879 if(sfx_voice[index]!=-1)
9252 {
9253 4849 deallocate_voice(sfx_voice[index]);
9254 4849 sfx_voice[index]=-1;
9255 4849 }
9256 2480588 }
9257
9258 // Stops SFX played by Hero's item of the given family
9259 4412 void stop_item_sfx(int32_t family)
9260 {
9261 4412 int32_t id=current_item_id(family);
9262
9263
2/2
✓ Branch 0 taken 4172 times.
✓ Branch 1 taken 240 times.
4412 if(id<0)
9264 4172 return;
9265
9266 240 stop_sfx(itemsbuf[id].usesound);
9267 4412 }
9268
9269 789 void kill_sfx()
9270 {
9271
2/2
✓ Branch 0 taken 201984 times.
✓ Branch 1 taken 789 times.
202773 for(int32_t i=0; i<WAV_COUNT; i++)
9272
2/2
✓ Branch 0 taken 200421 times.
✓ Branch 1 taken 1563 times.
203547 if(sfx_voice[i]!=-1)
9273 {
9274 1563 deallocate_voice(sfx_voice[i]);
9275 1563 sfx_voice[i]=-1;
9276 1563 }
9277 789 }
9278
9279 276955 int32_t pan(int32_t x)
9280 {
9281
1/4
✓ Branch 0 taken 276955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276955 switch(pan_style)
9282 {
9283 case 0:
9284 return 128;
9285
9286 case 1:
9287 276955 return vbound((x>>1)+68,0,255);
9288
9289 case 2:
9290 return vbound(((x*3)>>2)+36,0,255);
9291 }
9292
9293 return vbound(x,0,255);
9294 276955 }
9295
9296 /*******************************/
9297 /******* Input Handlers ********/
9298 /*******************************/
9299
9300 6014929 bool joybtn(int32_t b)
9301 {
9302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6014929 times.
6014929 if(b == 0)
9303 return false;
9304
9305 6014929 return joy[joystick_index].button[b-1].b !=0;
9306 6014929 }
9307
9308 const char* joybtn_name(int32_t b)
9309 {
9310 if(b == 0)
9311 return "";
9312
9313 return joy[joystick_index].button[b-1].name;
9314 }
9315
9316 int32_t next_press_key()
9317 {
9318 return readkey()>>8;
9319 }
9320
9321 int32_t next_press_btn()
9322 {
9323 clear_keybuf();
9324 /*bool b[joy[joystick_index].num_buttons+1];
9325
9326 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9327 b[i]=joybtn(i);*/
9328
9329 //first, we need to wait until they're pressing no buttons
9330 for(;;)
9331 {
9332 if(keypressed())
9333 {
9334 switch(readkey()>>8)
9335 {
9336 case KEY_ESC:
9337 return -1;
9338
9339 case KEY_SPACE:
9340 return 0;
9341 }
9342 }
9343
9344 poll_joystick();
9345 bool done = true;
9346
9347 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9348 {
9349 if(joybtn(i)) done = false;
9350 }
9351
9352 if(done) break;
9353 rest(1);
9354 }
9355
9356 //now, we need to wait for them to press any button
9357 for(;;)
9358 {
9359 if(keypressed())
9360 {
9361 switch(readkey()>>8)
9362 {
9363 case KEY_ESC:
9364 return -1;
9365
9366 case KEY_SPACE:
9367 return 0;
9368 }
9369 }
9370
9371 poll_joystick();
9372
9373 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9374 {
9375 if(joybtn(i)) return i;
9376 }
9377 rest(1);
9378 }
9379 }
9380
9381 static bool rButton(bool(proc)(),bool &flag)
9382 {
9383 if(!proc())
9384 {
9385 flag=false;
9386 }
9387 else if(!flag)
9388 {
9389 flag=true;
9390 return true;
9391 }
9392
9393 return false;
9394 }
9395
9396 62121982 static bool rButton(bool &btn, bool &flag)
9397 {
9398
2/2
✓ Branch 0 taken 2305536 times.
✓ Branch 1 taken 59816446 times.
62121982 if(!btn)
9399 {
9400 59816446 flag=false;
9401 59816446 }
9402
2/2
✓ Branch 0 taken 130264 times.
✓ Branch 1 taken 2175272 times.
2305536 else if(!flag)
9403 {
9404 130264 flag=true;
9405 130264 return true;
9406 }
9407
9408 61991718 return false;
9409 62121982 }
9410 619 static bool rButtonPeek(bool btn, bool flag)
9411 {
9412
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 36 times.
619 if(!btn)
9413 {
9414 583 return false;
9415 }
9416
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9417 {
9418 9 return true;
9419 }
9420
9421 27 return false;
9422 619 }
9423
9424 // Updated only by keyboard/gamepad.
9425 // If in replay mode, this is set directly by the replay system.
9426 // This should never be read from directly - use control_state instead.
9427 bool raw_control_state[ZC_CONTROL_STATES];
9428
9429 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9430 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9431 // lasts until the next call to load_control_state.
9432 bool control_state[ZC_CONTROL_STATES];
9433 bool disable_control[ZC_CONTROL_STATES];
9434 bool drunk_toggle_state[11];
9435 bool disabledKeys[127];
9436 bool KeyInput[127];
9437 bool KeyPress[127];
9438
9439 bool key_current_frame[127];
9440 bool key_previous_frame[127];
9441
9442 static bool key_system[127];
9443 static bool key_system_previous[127];
9444 static bool key_system_press[127];
9445
9446 bool button_press[ZC_CONTROL_STATES];
9447 bool button_hold[ZC_CONTROL_STATES];
9448
9449 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9450 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9451 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9452 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9453 #define STICK_PRECISION 56 //define your own sensitivity
9454
9455 2494958 void load_control_state()
9456 {
9457
1/2
✓ Branch 0 taken 2494958 times.
✗ Branch 1 not taken.
2494958 if (!replay_is_replaying())
9458 {
9459 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9460 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9461 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9462 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9463 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9464 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9465 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9466 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9467 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9468 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9469 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9470 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9471 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9472 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9473
9474 if(num_joysticks != 0)
9475 {
9476 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9477 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9478 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9479 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9480 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9481 }
9482 else
9483 {
9484 raw_control_state[14] = false;
9485 raw_control_state[15] = false;
9486 raw_control_state[16] = false;
9487 raw_control_state[17] = false;
9488 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9489 }
9490 }
9491
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2494955 times.
2494958 if (replay_is_active())
9492 {
9493
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 1479740 times.
2494955 if (replay_get_version() < 3)
9494 1015215 replay_poll();
9495
3/4
✓ Branch 0 taken 1479740 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9443 times.
✓ Branch 3 taken 1470297 times.
1479740 else if (replay_is_replaying() && replay_get_version() < 6)
9496 1470297 replay_peek_input();
9497 2494955 }
9498
9499 // Some test replay files were made before a serious input bug was fixed, so instead
9500 // of re-doing them or tossing them out, just check for that zplay version.
9501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2494952 times.
2494958 bool botched_input = replay_is_replaying() && replay_get_version() == 1;
9502
2/2
✓ Branch 0 taken 2494952 times.
✓ Branch 1 taken 44909136 times.
47404088 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9503 {
9504 44909136 control_state[i] = raw_control_state[i];
9505
4/4
✓ Branch 0 taken 42714936 times.
✓ Branch 1 taken 2194200 times.
✓ Branch 2 taken 2087228 times.
✓ Branch 3 taken 40627708 times.
44909136 if(!botched_input && !control_state[i])
9506 40627708 down_control_states[i] = false;
9507 44909136 }
9508
9509 2494952 button_press[0]=rButton(control_state[0],button_hold[0]);
9510 2494952 button_press[1]=rButton(control_state[1],button_hold[1]);
9511 2494952 button_press[2]=rButton(control_state[2],button_hold[2]);
9512 2494952 button_press[3]=rButton(control_state[3],button_hold[3]);
9513 2494952 button_press[4]=rButton(control_state[4],button_hold[4]);
9514 2494952 button_press[5]=rButton(control_state[5],button_hold[5]);
9515 2494952 button_press[6]=rButton(control_state[6],button_hold[6]);
9516 2494952 button_press[7]=rButton(control_state[7],button_hold[7]);
9517 2494952 button_press[8]=rButton(control_state[8],button_hold[8]);
9518 2494952 button_press[9]=rButton(control_state[9],button_hold[9]);
9519 2494952 button_press[10]=rButton(control_state[10],button_hold[10]);
9520 2494952 button_press[11]=rButton(control_state[11],button_hold[11]);
9521 2494952 button_press[12]=rButton(control_state[12],button_hold[12]);
9522 2494952 button_press[13]=rButton(control_state[13],button_hold[13]);
9523 2494952 button_press[14]=rButton(control_state[14],button_hold[14]);
9524 2494952 button_press[15]=rButton(control_state[15],button_hold[15]);
9525 2494952 button_press[16]=rButton(control_state[16],button_hold[16]);
9526 2494952 button_press[17]=rButton(control_state[17],button_hold[17]);
9527 2494952 }
9528
9529 // Returns true if any game key is pressed. This is needed because keypressed()
9530 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9531 12337506 bool zc_key_pressed()
9532 //may also need to use zc_getrawkey
9533 {
9534
7/10
✓ Branch 0 taken 9835652 times.
✓ Branch 1 taken 2501854 times.
✓ Branch 2 taken 2501854 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2501854 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2084071 times.
✓ Branch 7 taken 2084071 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 586494 times.
12924000 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9535
4/6
✓ Branch 0 taken 2084071 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2084071 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1527166 times.
✓ Branch 5 taken 1527166 times.
2084071 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9536
4/6
✓ Branch 0 taken 1527166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1527166 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 924201 times.
✓ Branch 5 taken 924201 times.
1527166 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9537
4/6
✓ Branch 0 taken 924201 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 924201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 685551 times.
✓ Branch 5 taken 685551 times.
924201 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9538
1/2
✓ Branch 0 taken 685551 times.
✗ Branch 1 not taken.
685551 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9539
3/4
✓ Branch 0 taken 625214 times.
✓ Branch 1 taken 60337 times.
✓ Branch 2 taken 625214 times.
✗ Branch 3 not taken.
685551 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9540
3/4
✓ Branch 0 taken 594187 times.
✓ Branch 1 taken 31027 times.
✓ Branch 2 taken 594187 times.
✗ Branch 3 not taken.
625214 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9541
3/4
✓ Branch 0 taken 590966 times.
✓ Branch 1 taken 3221 times.
✓ Branch 2 taken 590966 times.
✗ Branch 3 not taken.
594187 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9542
3/4
✓ Branch 0 taken 586541 times.
✓ Branch 1 taken 4425 times.
✓ Branch 2 taken 586541 times.
✗ Branch 3 not taken.
590966 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9543
3/4
✓ Branch 0 taken 586494 times.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 586494 times.
✗ Branch 3 not taken.
586541 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9544
2/4
✓ Branch 0 taken 586494 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 586494 times.
✗ Branch 3 not taken.
586494 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9545
2/4
✓ Branch 0 taken 586494 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 586494 times.
✗ Branch 3 not taken.
586494 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9546
2/4
✓ Branch 0 taken 586494 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 586494 times.
✗ Branch 3 not taken.
586494 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9547
1/2
✓ Branch 0 taken 586494 times.
✗ Branch 1 not taken.
586494 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9548 22192990 return true;
9549
9550 586494 return false;
9551 3108180 }
9552
9553 50238575 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9554 {
9555 50238575 bool ret = false, drunkstate = false;
9556 50238575 bool* flag = &down_control_states[btn];
9557
2/7
✓ Branch 0 taken 47126731 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3111844 times.
50238575 switch(btn)
9558 {
9559 case btnF12:
9560 ret = zc_getkey(KEY_F12, ignoreDisable);
9561 eatEntirely = false;
9562 break;
9563 case btnF11:
9564 ret = zc_getkey(KEY_F11, ignoreDisable);
9565 eatEntirely = false;
9566 break;
9567 case btnF5:
9568 ret = zc_getkey(KEY_F5, ignoreDisable);
9569 eatEntirely = false;
9570 break;
9571 case btnQ:
9572 ret = zc_getkey(KEY_Q, ignoreDisable);
9573 eatEntirely = false;
9574 break;
9575 case btnI:
9576 ret = zc_getkey(KEY_I, ignoreDisable);
9577 eatEntirely = false;
9578 break;
9579 case btnM:
9580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3111844 times.
3111844 if(FFCore.kb_typing_mode) return false;
9581 3111844 ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9582 3111844 eatEntirely = false;
9583 3111844 break;
9584 default: //control_state[] index
9585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47126731 times.
47126731 if(FFCore.kb_typing_mode) return false;
9586
5/6
✓ Branch 0 taken 47071146 times.
✓ Branch 1 taken 55585 times.
✓ Branch 2 taken 246208 times.
✓ Branch 3 taken 46824938 times.
✓ Branch 4 taken 246208 times.
✗ Branch 5 not taken.
47126731 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9587
2/2
✓ Branch 0 taken 2532108 times.
✓ Branch 1 taken 44594623 times.
47126731 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9588
4/4
✓ Branch 0 taken 42114836 times.
✓ Branch 1 taken 5011895 times.
✓ Branch 2 taken 932 times.
✓ Branch 3 taken 5010963 times.
52138626 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9589 47126731 }
9590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50238575 times.
50238575 assert(flag);
9591
2/2
✓ Branch 0 taken 33025110 times.
✓ Branch 1 taken 17213465 times.
50238575 if(press)
9592 {
9593
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 17212846 times.
17213465 if(peek)
9594 619 ret = rButtonPeek(ret, *flag);
9595 17212846 else ret = rButton(ret, *flag);
9596 17213465 }
9597
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50238575 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50238575 if(eatEntirely && ret) control_state[btn] = false;
9598
3/4
✓ Branch 0 taken 38729736 times.
✓ Branch 1 taken 11508839 times.
✓ Branch 2 taken 38729736 times.
✗ Branch 3 not taken.
50238575 if(drunk && drunkstate) ret = !ret;
9599 50238575 return ret;
9600 50238575 }
9601
9602 16975 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9603 {
9604 16975 byte ret = 0;
9605
2/2
✓ Branch 0 taken 16356 times.
✓ Branch 1 taken 619 times.
16975 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9606
1/2
✓ Branch 0 taken 16975 times.
✗ Branch 1 not taken.
16975 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9607
1/2
✓ Branch 0 taken 16975 times.
✗ Branch 1 not taken.
16975 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9608
1/2
✓ Branch 0 taken 16975 times.
✗ Branch 1 not taken.
16975 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9609
1/2
✓ Branch 0 taken 16975 times.
✗ Branch 1 not taken.
16975 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9610
1/2
✓ Branch 0 taken 16975 times.
✗ Branch 1 not taken.
16975 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9611
1/2
✓ Branch 0 taken 16975 times.
✗ Branch 1 not taken.
16975 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9612
1/2
✓ Branch 0 taken 16975 times.
✗ Branch 1 not taken.
16975 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9613 16975 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9614 }
9615
9616 byte checkIntBtnVal(byte intbtn, byte vals)
9617 {
9618 return intbtn&vals;
9619 }
9620
9621 498084 bool Up()
9622 {
9623 498084 return getInput(btnUp);
9624 }
9625 4415 bool Down()
9626 {
9627 4415 return getInput(btnDown);
9628 }
9629 6638 bool Left()
9630 {
9631 6638 return getInput(btnLeft);
9632 }
9633 6681 bool Right()
9634 {
9635 6681 return getInput(btnRight);
9636 }
9637 23020 bool cAbtn()
9638 {
9639 23020 return getInput(btnA);
9640 }
9641 521691 bool cBbtn()
9642 {
9643 521691 return getInput(btnB);
9644 }
9645 bool cSbtn()
9646 {
9647 return getInput(btnS);
9648 }
9649 296 bool cLbtn()
9650 {
9651 296 return getInput(btnL);
9652 }
9653 296 bool cRbtn()
9654 {
9655 296 return getInput(btnR);
9656 }
9657 bool cPbtn()
9658 {
9659 return getInput(btnP);
9660 }
9661 bool cEx1btn()
9662 {
9663 return getInput(btnEx1);
9664 }
9665 bool cEx2btn()
9666 {
9667 return getInput(btnEx2);
9668 }
9669 bool cEx3btn()
9670 {
9671 return getInput(btnEx3);
9672 }
9673 bool cEx4btn()
9674 {
9675 return getInput(btnEx4);
9676 }
9677 bool AxisUp()
9678 {
9679 return getInput(btnAxisUp);
9680 }
9681 bool AxisDown()
9682 {
9683 return getInput(btnAxisDown);
9684 }
9685 bool AxisLeft()
9686 {
9687 return getInput(btnAxisLeft);
9688 }
9689 bool AxisRight()
9690 {
9691 return getInput(btnAxisRight);
9692 }
9693
9694 bool cMbtn()
9695 {
9696 return getInput(btnM);
9697 }
9698 bool cF12()
9699 {
9700 return getInput(btnF12);
9701 }
9702 bool cF11()
9703 {
9704 return getInput(btnF11);
9705 }
9706 bool cF5()
9707 {
9708 return getInput(btnF5);
9709 }
9710 bool cQ()
9711 {
9712 return getInput(btnQ);
9713 }
9714 bool cI()
9715 {
9716 return getInput(btnI);
9717 }
9718
9719 40188 bool rUp()
9720 {
9721 40188 return getInput(btnUp, true);
9722 }
9723 40151 bool rDown()
9724 {
9725 40151 return getInput(btnDown, true);
9726 }
9727 40141 bool rLeft()
9728 {
9729 40141 return getInput(btnLeft, true);
9730 }
9731 39855 bool rRight()
9732 {
9733 39855 return getInput(btnRight, true);
9734 }
9735 303 bool rAbtn()
9736 {
9737 303 return getInput(btnA, true);
9738 }
9739 40491 bool rBbtn()
9740 {
9741 40491 return getInput(btnB, true);
9742 }
9743 2482552 bool rSbtn()
9744 {
9745 2482552 return getInput(btnS, true);
9746 }
9747 3108180 bool rMbtn()
9748 {
9749 3108180 return getInput(btnM, true);
9750 }
9751 39739 bool rLbtn()
9752 {
9753 39739 return getInput(btnL, true);
9754 }
9755 39736 bool rRbtn()
9756 {
9757 39736 return getInput(btnR, true);
9758 }
9759 2442180 bool rPbtn()
9760 {
9761 2442180 return getInput(btnP, true);
9762 }
9763 bool rEx1btn()
9764 {
9765 return getInput(btnEx1, true);
9766 }
9767 bool rEx2btn()
9768 {
9769 return getInput(btnEx2, true);
9770 }
9771 39735 bool rEx3btn()
9772 {
9773 39735 return getInput(btnEx3, true);
9774 }
9775 39735 bool rEx4btn()
9776 {
9777 39735 return getInput(btnEx4, true);
9778 }
9779 bool rAxisUp()
9780 {
9781 return getInput(btnAxisUp, true);
9782 }
9783 bool rAxisDown()
9784 {
9785 return getInput(btnAxisDown, true);
9786 }
9787 bool rAxisLeft()
9788 {
9789 return getInput(btnAxisLeft, true);
9790 }
9791 bool rAxisRight()
9792 {
9793 return getInput(btnAxisRight, true);
9794 }
9795
9796 bool rF11()
9797 {
9798 return getInput(btnF11, true);
9799 }
9800 bool rQ()
9801 {
9802 return getInput(btnQ, true);
9803 }
9804 bool rI()
9805 {
9806 return getInput(btnI, true);
9807 }
9808
9809 6373010 bool DrunkUp()
9810 {
9811 6373010 return getInput(btnUp, false, true);
9812 }
9813 5951818 bool DrunkDown()
9814 {
9815 5951818 return getInput(btnDown, false, true);
9816 }
9817 3956244 bool DrunkLeft()
9818 {
9819 3956244 return getInput(btnLeft, false, true);
9820 }
9821 3496015 bool DrunkRight()
9822 {
9823 3496015 return getInput(btnRight, false, true);
9824 }
9825 2819946 bool DrunkcAbtn()
9826 {
9827 2819946 return getInput(btnA, false, true);
9828 }
9829 2488181 bool DrunkcBbtn()
9830 {
9831 2488181 return getInput(btnB, false, true);
9832 }
9833 2441646 bool DrunkcEx1btn()
9834 {
9835 2441646 return getInput(btnEx1, false, true);
9836 }
9837 2441646 bool DrunkcEx2btn()
9838 {
9839 2441646 return getInput(btnEx2, false, true);
9840 }
9841 bool DrunkcSbtn()
9842 {
9843 return getInput(btnS, false, true);
9844 }
9845 bool DrunkcMbtn()
9846 {
9847 return getInput(btnM, false, true);
9848 }
9849 bool DrunkcLbtn()
9850 {
9851 return getInput(btnL, false, true);
9852 }
9853 bool DrunkcRbtn()
9854 {
9855 return getInput(btnR, false, true);
9856 }
9857 bool DrunkcPbtn()
9858 {
9859 return getInput(btnP, false, true);
9860 }
9861
9862 bool DrunkrUp()
9863 {
9864 return getInput(btnUp, true, true);
9865 }
9866 bool DrunkrDown()
9867 {
9868 return getInput(btnDown, true, true);
9869 }
9870 bool DrunkrLeft()
9871 {
9872 return getInput(btnLeft, true, true);
9873 }
9874 bool DrunkrRight()
9875 {
9876 return getInput(btnRight, true, true);
9877 }
9878 1940113 bool DrunkrAbtn()
9879 {
9880 1940113 return getInput(btnA, true, true);
9881 }
9882 1937736 bool DrunkrBbtn()
9883 {
9884 1937736 return getInput(btnB, true, true);
9885 }
9886 bool DrunkrEx1btn()
9887 {
9888 return getInput(btnEx1, true, true);
9889 }
9890 bool DrunkrEx2btn()
9891 {
9892 return getInput(btnEx2, true, true);
9893 }
9894 bool DrunkrEx3btn()
9895 {
9896 return getInput(btnEx3, true, true);
9897 }
9898 bool DrunkrEx4btn()
9899 {
9900 return getInput(btnEx4, true, true);
9901 }
9902 bool DrunkrSbtn()
9903 {
9904 return getInput(btnS, true, true);
9905 }
9906 bool DrunkrMbtn()
9907 {
9908 return getInput(btnM, true, true);
9909 }
9910 2441884 bool DrunkrLbtn()
9911 {
9912 2441884 return getInput(btnL, true, true);
9913 }
9914 2440878 bool DrunkrRbtn()
9915 {
9916 2440878 return getInput(btnR, true, true);
9917 }
9918 bool DrunkrPbtn()
9919 {
9920 return getInput(btnP, true, true);
9921 }
9922
9923 3664 void eat_buttons()
9924 {
9925 3664 getInput(btnA, true, false, true);
9926 3664 getInput(btnB, true, false, true);
9927 3664 getInput(btnS, true, false, true);
9928 3664 getInput(btnM, true, false, true);
9929 3664 getInput(btnL, true, false, true);
9930 3664 getInput(btnR, true, false, true);
9931 3664 getInput(btnP, true, false, true);
9932 3664 getInput(btnEx1, true, false, true);
9933 3664 getInput(btnEx2, true, false, true);
9934 3664 getInput(btnEx3, true, false, true);
9935 3664 getInput(btnEx4, true, false, true);
9936 3664 }
9937
9938 // Is true for the _first frame_ of a key press.
9939 // But! it is possible that a script manually sets the value of KeyPress,
9940 // in which case it will be restored to the "true" value based on `key_current_frame`
9941 // and `key_previous_frame` on the next frame.
9942 1 bool zc_readkey(int32_t k, bool ignoreDisable)
9943 {
9944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(ignoreDisable) return KeyPress[k];
9945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 switch(k)
9946 {
9947 case KEY_F7:
9948 case KEY_F8:
9949 case KEY_F9:
9950 return KeyPress[k];
9951
9952 default:
9953
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 return KeyPress[k] && !disabledKeys[k];
9954 }
9955 1 }
9956
9957 // Is true for _every frame_ a key is held down.
9958 // But! it is possible that a script manually sets the value of KeyInput,
9959 // in which case it will be restored to the "true" value based on `key_current_frame`
9960 // on the next frame.
9961 bool zc_getkey(int32_t k, bool ignoreDisable)
9962 {
9963 if(ignoreDisable) return KeyInput[k];
9964 switch(k)
9965 {
9966 case KEY_F7:
9967 case KEY_F8:
9968 case KEY_F9:
9969 return KeyInput[k];
9970
9971 default:
9972 return KeyInput[k] && !disabledKeys[k];
9973 }
9974 }
9975
9976 // Reads (and then clears) the current frame key state directly.
9977 // Scripts can also modify `key_current_frame`.
9978 3936309 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9979 {
9980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3936309 times.
3936309 if(zc_getrawkey(k, ignoreDisable))
9981 {
9982 _key[k]=key[k]=key_current_frame[k]=0;
9983 return true;
9984 }
9985 3936309 _key[k]=key[k]=key_current_frame[k]=0;
9986 3936309 return false;
9987 3936309 }
9988
9989 // Reads the current frame key state directly.
9990 // Scripts can also modify `key_current_frame`.
9991 22622060 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9992 {
9993
2/2
✓ Branch 0 taken 15577572 times.
✓ Branch 1 taken 7044488 times.
22622060 if(ignoreDisable) return key_current_frame[k];
9994
2/2
✓ Branch 0 taken 3936306 times.
✓ Branch 1 taken 3108182 times.
7044488 switch(k)
9995 {
9996 case KEY_F7:
9997 case KEY_F8:
9998 case KEY_F9:
9999 3936306 return key_current_frame[k];
10000
10001 default:
10002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3108182 times.
3108182 return key_current_frame[k] && !disabledKeys[k];
10003 }
10004 22622060 }
10005
10006 // Only used for a handful of keys, like tilde and Function keys.
10007 // This state is never read within the game.
10008 // It exists so that all keyboard input still functions during replay,
10009 // without inadvertently doing things like toggling throttling if the player
10010 // presses ~
10011 6122193 bool zc_get_system_key(int32_t k)
10012 {
10013 6122193 return key_system[k];
10014 }
10015
10016 // True for the _first_ frame of a key press.
10017 34189980 bool zc_read_system_key(int32_t k)
10018 {
10019 34189980 return key_system_press[k];
10020 }
10021
10022 394738860 bool is_system_key(int32_t k)
10023 {
10024
2/2
✓ Branch 0 taken 366765240 times.
✓ Branch 1 taken 27973620 times.
394738860 switch (k)
10025 {
10026 case KEY_BACKQUOTE:
10027 case KEY_CLOSEBRACE:
10028 case KEY_END:
10029 case KEY_HOME:
10030 case KEY_OPENBRACE:
10031 case KEY_PGDN:
10032 case KEY_PGUP:
10033 case KEY_TAB:
10034 case KEY_TILDE:
10035 27973620 return true;
10036 }
10037 366765240 return is_Fkey(k);
10038 394738860 }
10039
10040 3108180 void update_system_keys()
10041 {
10042 3108180 poll_keyboard();
10043
2/2
✓ Branch 0 taken 394738860 times.
✓ Branch 1 taken 3108180 times.
397847040 for (int32_t q = 0; q < 127; ++q)
10044 {
10045
2/2
✓ Branch 0 taken 65271780 times.
✓ Branch 1 taken 329467080 times.
394738860 if (!is_system_key(q))
10046 329467080 continue;
10047
10048 65271780 key_system[q] = key[q];
10049
1/2
✓ Branch 0 taken 65271780 times.
✗ Branch 1 not taken.
65271780 key_system_press[q] = key_system[q] && !key_system_previous[q];
10050 65271780 key_system_previous[q] = key_system[q];
10051 65271780 }
10052 3108180 }
10053
10054 3061096 void update_keys()
10055 {
10056
1/2
✓ Branch 0 taken 3061096 times.
✗ Branch 1 not taken.
3061096 if (!replay_is_replaying())
10057 poll_keyboard();
10058
10059
2/2
✓ Branch 0 taken 3061096 times.
✓ Branch 1 taken 388759192 times.
391820288 for (int32_t q = 0; q < 127; ++q)
10060 {
10061 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10062
1/2
✓ Branch 0 taken 388759192 times.
✗ Branch 1 not taken.
388759192 if (!replay_is_replaying())
10063 key_current_frame[q] = key[q];
10064
10065
2/2
✓ Branch 0 taken 385989606 times.
✓ Branch 1 taken 2769586 times.
388759192 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10066
3/4
✓ Branch 0 taken 97315 times.
✓ Branch 1 taken 388661877 times.
✓ Branch 2 taken 97315 times.
✗ Branch 3 not taken.
388759192 if (KeyPress[q] && q == KEY_B) {
10067 int lol = 1;
10068 }
10069 388759192 KeyInput[q] = key_current_frame[q];
10070 388759192 key_previous_frame[q] = key_current_frame[q];
10071 388759192 }
10072 3061096 }
10073
10074 bool zc_disablekey(int32_t k, bool val)
10075 {
10076 switch(k)
10077 {
10078 case KEY_F7:
10079 case KEY_F8:
10080 case KEY_F9:
10081 return false;
10082
10083 default:
10084 disabledKeys[k] = val;
10085 return true;
10086 }
10087 }
10088
10089 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10090 {
10091 timer=timer;
10092 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10093 }
10094
10095 // these are here so that copy_dialog won't choke when compiling zelda
10096 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10097 {
10098 return D_O_K;
10099 }
10100
10101 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10102 {
10103 return D_O_K;
10104 }
10105
10106 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10107 {
10108 return D_O_K;
10109 }
10110
10111 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10112 {
10113 return D_O_K;
10114 }
10115
10116 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10117 {
10118 return D_O_K;
10119 }
10120
10121 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10122 {
10123 return D_O_K;
10124 }
10125
10126 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10127 {
10128 return D_O_K;
10129 }
10130
10131 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10132 {
10133 return D_O_K;
10134 }
10135
10136 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10137 {
10138 return D_O_K;
10139 }
10140
10141 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10142 {
10143 return D_O_K;
10144 }
10145
10146 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10147 {
10148 return D_O_K;
10149 }
10150
10151 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10152 {
10153 return D_O_K;
10154 }
10155
10156 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10157 {
10158 return D_O_K;
10159 }
10160
10161 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10162 {
10163 return D_O_K;
10164 }
10165
10166 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10167 {
10168 return D_O_K;
10169 }
10170
10171 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10172 {
10173 return D_O_K;
10174 }
10175
10176 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10177 {
10178 return D_O_K;
10179 }
10180
10181 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10182 {
10183 return D_O_K;
10184 }
10185
10186 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10187 {
10188 return D_O_K;
10189 }
10190
10191 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10192 {
10193 return D_O_K;
10194 }
10195
10196 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10197 {
10198 return D_O_K;
10199 }
10200
10201 /*** end of zc_sys.cc ***/
10202
10203